fixes some issues with the latest version of php-cs-fixer and runs it on all files. solved the ci hangs we are seeing in #5528 and #5512 Co-authored-by: Darragh Elliott <me@delliott.net> Reviewed-on: #5538 Co-authored-by: delliott <delliott@fsfe.org> Co-committed-by: delliott <delliott@fsfe.org>
This commit was merged in pull request #5538.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
|
||||
return (new Config())
|
||||
->setRiskyAllowed(false)
|
||||
->setRules([
|
||||
'@PhpCsFixer' => true,
|
||||
])
|
||||
->setFinder(
|
||||
(new Finder())
|
||||
->in(__DIR__)
|
||||
->exclude(['thirdparty'])
|
||||
->name('*.php')
|
||||
)
|
||||
;
|
||||
@@ -4,43 +4,45 @@
|
||||
// to the community database (occasional emails and the newsletter)
|
||||
|
||||
// parse data from POST or cli arg
|
||||
if (php_sapi_name() === 'cli') {
|
||||
if ('cli' === php_sapi_name()) {
|
||||
$data = json_decode($argv[1], true);
|
||||
} else {
|
||||
$data = $_POST;
|
||||
}
|
||||
|
||||
# Generic function to make POST request
|
||||
// Generic function to make POST request
|
||||
function mail_signup($url, $data)
|
||||
{
|
||||
$context = stream_context_create(
|
||||
array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'user_agent' => 'FSFE mail-signup.php',
|
||||
'content' => http_build_query($data),
|
||||
'timeout' => 10
|
||||
)
|
||||
)
|
||||
[
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'user_agent' => 'FSFE mail-signup.php',
|
||||
'content' => http_build_query($data),
|
||||
'timeout' => 10,
|
||||
],
|
||||
]
|
||||
);
|
||||
// DEBUG: set a local URL here to catch the requests
|
||||
file_get_contents($url, false, $context);
|
||||
}
|
||||
|
||||
# Check expected/required variables are set
|
||||
if (empty($data['email1']) ||
|
||||
empty($data['name']) ||
|
||||
empty($data['address']) ||
|
||||
empty($data['zip']) ||
|
||||
empty($data['city'])) {
|
||||
echo "Missing parameters. Some required parameters are missing (name, address, mail)";
|
||||
// Check expected/required variables are set
|
||||
if (empty($data['email1'])
|
||||
|| empty($data['name'])
|
||||
|| empty($data['address'])
|
||||
|| empty($data['zip'])
|
||||
|| empty($data['city'])) {
|
||||
echo 'Missing parameters. Some required parameters are missing (name, address, mail)';
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($data['wants_info'] or $data['wants_newsletter_info']) {
|
||||
mail_signup('https://my.fsfe.org/subscribe-api', $signupdata);
|
||||
} else {
|
||||
echo "List to sign up email to is unknown. Exiting.";
|
||||
echo 'List to sign up email to is unknown. Exiting.';
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
+105
-107
@@ -15,36 +15,36 @@
|
||||
*/
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
|
||||
require 'PHPMailer/Exception.php';
|
||||
|
||||
require 'PHPMailer/PHPMailer.php';
|
||||
|
||||
require 'PHPMailer/SMTP.php';
|
||||
|
||||
$html = ''; // create empty variable
|
||||
$csv = array(array("Employee number", "Employee name", "Date", "Amount (EUR)", "Recipient name", "Activity Tag", "Activity Text", "Category ID", "Category Text", "Event", "Description", "Receipt number")); // create array for CSV
|
||||
$csv = [['Employee number', 'Employee name', 'Date', 'Amount (EUR)', 'Recipient name', 'Activity Tag', 'Activity Text', 'Category ID', 'Category Text', 'Event', 'Description', 'Receipt number']]; // create array for CSV
|
||||
$csvfile = tmpfile();
|
||||
$csvfile_path = stream_get_meta_data($csvfile)['uri'];
|
||||
$reimb_total = 0; // total reimbursement for early calculation
|
||||
|
||||
$who = isset($_POST["who"]) ? $_POST["who"] : false;
|
||||
$activity = isset($_POST["activity"]) ? $_POST["activity"] : false;
|
||||
$activity_tag = explode("||", $activity)[0];
|
||||
$activity_text = explode("||", $activity)[1];
|
||||
$category_id = "66640";
|
||||
$category_text = "Per diem";
|
||||
$event = isset($_POST["event"]) ? $_POST["event"] : false;
|
||||
$extra = isset($_POST["extra"]) ? $_POST["extra"] : false;
|
||||
$mailopt = isset($_POST["mailopt"]) ? $_POST["mailopt"] : false;
|
||||
$defaults = isset($_POST["defaults"]) ? $_POST["defaults"] : false;
|
||||
$dest = isset($_POST["dest"]) ? $_POST["dest"] : false;
|
||||
$dest_other = isset($_POST["dest_other"]) ? $_POST["dest_other"] : false;
|
||||
$use = isset($_POST["use"]) ? $_POST["use"] : false;
|
||||
$date = isset($_POST["date"]) ? $_POST["date"] : false;
|
||||
$break = isset($_POST["break"]) ? $_POST["break"] : false;
|
||||
$lunch = isset($_POST["lunch"]) ? $_POST["lunch"] : false;
|
||||
$dinner = isset($_POST["dinner"]) ? $_POST["dinner"] : false;
|
||||
$who = isset($_POST['who']) ? $_POST['who'] : false;
|
||||
$activity = isset($_POST['activity']) ? $_POST['activity'] : false;
|
||||
$activity_tag = explode('||', $activity)[0];
|
||||
$activity_text = explode('||', $activity)[1];
|
||||
$category_id = '66640';
|
||||
$category_text = 'Per diem';
|
||||
$event = isset($_POST['event']) ? $_POST['event'] : false;
|
||||
$extra = isset($_POST['extra']) ? $_POST['extra'] : false;
|
||||
$mailopt = isset($_POST['mailopt']) ? $_POST['mailopt'] : false;
|
||||
$defaults = isset($_POST['defaults']) ? $_POST['defaults'] : false;
|
||||
$dest = isset($_POST['dest']) ? $_POST['dest'] : false;
|
||||
$dest_other = isset($_POST['dest_other']) ? $_POST['dest_other'] : false;
|
||||
$use = isset($_POST['use']) ? $_POST['use'] : false;
|
||||
$date = isset($_POST['date']) ? $_POST['date'] : false;
|
||||
$break = isset($_POST['break']) ? $_POST['break'] : false;
|
||||
$lunch = isset($_POST['lunch']) ? $_POST['lunch'] : false;
|
||||
$dinner = isset($_POST['dinner']) ? $_POST['dinner'] : false;
|
||||
|
||||
// Separate employee name parameters
|
||||
$who_verbose = explode('||', $who)[0];
|
||||
@@ -54,11 +54,12 @@ $who = explode('||', $who)[1];
|
||||
// FUNCTIONS
|
||||
function errexit($msg)
|
||||
{
|
||||
exit("Error: " . $msg . "<br/><br/>To avoid losing your data, press the back button in your browser");
|
||||
exit('Error: '.$msg.'<br/><br/>To avoid losing your data, press the back button in your browser');
|
||||
}
|
||||
function replace_page($temp, $content)
|
||||
{
|
||||
$vars = array(':RESULT:' => $content);
|
||||
$vars = [':RESULT:' => $content];
|
||||
|
||||
return str_replace(array_keys($vars), $vars, $temp);
|
||||
}
|
||||
/* Snippet Begin:
|
||||
@@ -70,7 +71,7 @@ function filter_filename($filename, $beautify = true)
|
||||
// sanitize filename
|
||||
$filename = preg_replace(
|
||||
'~
|
||||
[<>:"/\\|?*]| # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
|
||||
[<>:"/\|?*]| # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
|
||||
[\x00-\x1F]| # control characters http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
|
||||
[\x7F\xA0\xAD]| # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN
|
||||
[#\[\]@!$&\'()+,;=]| # URI reserved https://tools.ietf.org/html/rfc3986#section-2.2
|
||||
@@ -87,47 +88,46 @@ function filter_filename($filename, $beautify = true)
|
||||
}
|
||||
// maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$filename = mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)) . ($ext ? '.' . $ext : '');
|
||||
return $filename;
|
||||
|
||||
return mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)).($ext ? '.'.$ext : '');
|
||||
}
|
||||
function beautify_filename($filename)
|
||||
{
|
||||
// reduce consecutive characters
|
||||
$filename = preg_replace(array(
|
||||
// "file name.zip" becomes "file-name.zip"
|
||||
'/ +/',
|
||||
// "file___name.zip" becomes "file-name.zip"
|
||||
'/_+/',
|
||||
// "file---name.zip" becomes "file-name.zip"
|
||||
'/-+/'
|
||||
), '-', $filename);
|
||||
$filename = preg_replace(array(
|
||||
// "file--.--.-.--name.zip" becomes "file.name.zip"
|
||||
'/-*\.-*/',
|
||||
// "file...name..zip" becomes "file.name.zip"
|
||||
'/\.{2,}/'
|
||||
), '.', $filename);
|
||||
$filename = preg_replace([
|
||||
// "file name.zip" becomes "file-name.zip"
|
||||
'/ +/',
|
||||
// "file___name.zip" becomes "file-name.zip"
|
||||
'/_+/',
|
||||
// "file---name.zip" becomes "file-name.zip"
|
||||
'/-+/',
|
||||
], '-', $filename);
|
||||
$filename = preg_replace([
|
||||
// "file--.--.-.--name.zip" becomes "file.name.zip"
|
||||
'/-*\.-*/',
|
||||
// "file...name..zip" becomes "file.name.zip"
|
||||
'/\.{2,}/',
|
||||
], '.', $filename);
|
||||
// lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625
|
||||
$filename = mb_strtolower($filename, mb_detect_encoding($filename));
|
||||
// ".file-name.-" becomes "file-name"
|
||||
$filename = trim($filename, '.-');
|
||||
return $filename;
|
||||
}
|
||||
/* Snippet End */
|
||||
|
||||
// ".file-name.-" becomes "file-name"
|
||||
return trim($filename, '.-');
|
||||
}
|
||||
// Snippet End
|
||||
|
||||
// Take currency and meal rates for the default country. Other home countries are not supported.
|
||||
$defaults = explode("/", $defaults);
|
||||
$currency = " " . $defaults[0]; // currency
|
||||
$defaults = explode('/', $defaults);
|
||||
$currency = ' '.$defaults[0]; // currency
|
||||
$rate_breakf = floatval($defaults[1]); // breakfast rate
|
||||
$rate_lunch = floatval($defaults[2]); // lunch rate
|
||||
$rate_dinner = floatval($defaults[3]); // dinner rate
|
||||
|
||||
// eligible amount per day
|
||||
if ($dest === 'other') {
|
||||
if ('other' === $dest) {
|
||||
$dest = $dest_other; // if other destination, just take this value
|
||||
} else {
|
||||
$pattern = "/([0-9.]+)?\/([0-9.]+)?/"; // define pattern something like "/12/24/"
|
||||
$pattern = '/([0-9.]+)?\/([0-9.]+)?/'; // define pattern something like "/12/24/"
|
||||
$dest = preg_match($pattern, $dest, $match, PREG_OFFSET_CAPTURE); // actually search for it
|
||||
$dest = $match[0][0]; // matches are on 2nd level in an array
|
||||
}
|
||||
@@ -138,12 +138,12 @@ $maxamount_trav = floatval($maxamount[0]); // first half
|
||||
$maxamount_full = floatval($maxamount[1]); // second half
|
||||
|
||||
// Prepare output table
|
||||
if ($mailopt === "onlyme") {
|
||||
$html .= "<p><strong>ATTENTION: The email has only been sent to you, not to the financial team!</strong></p>";
|
||||
} elseif ($mailopt === "none") {
|
||||
$html .= "<p><strong>ATTENTION: You have configured to not send any email!</strong></p>";
|
||||
if ('onlyme' === $mailopt) {
|
||||
$html .= '<p><strong>ATTENTION: The email has only been sent to you, not to the financial team!</strong></p>';
|
||||
} elseif ('none' === $mailopt) {
|
||||
$html .= '<p><strong>ATTENTION: You have configured to not send any email!</strong></p>';
|
||||
}
|
||||
$html .= "<p>This per diem statement is made by <strong>$who_verbose</strong>.</p>
|
||||
$html .= "<p>This per diem statement is made by <strong>{$who_verbose}</strong>.</p>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
@@ -160,24 +160,23 @@ $html .= "<p>This per diem statement is made by <strong>$who_verbose</strong>.</
|
||||
// Prepare email
|
||||
$email = new PHPMailer();
|
||||
$email->isSMTP();
|
||||
$email->Host = "mail.fsfe.org";
|
||||
$email->Host = 'mail.fsfe.org';
|
||||
// Settings on server
|
||||
$email->SMTPAuth = false;
|
||||
$email->Port = 25;
|
||||
$email->SMTPAuth = false;
|
||||
$email->Port = 25;
|
||||
// Settings for local debug
|
||||
//$email->SMTPAuth = true;
|
||||
//$email->Port = 587;
|
||||
//$email->Username = 'fsfe_user';
|
||||
//$email->Password = 'fsfe_pass';
|
||||
//$email->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$email->SetFrom($who . "@fsfe.org", $who_verbose);
|
||||
$email->CharSet = "UTF-8";
|
||||
$email->Subject = "=?UTF-8?B?" . base64_encode("per diem statement by $who_verbose for $activity_text") . "?=";
|
||||
if ($mailopt === "normal") {
|
||||
$email->addAddress("finance@lists.fsfe.org");
|
||||
// $email->SMTPAuth = true;
|
||||
// $email->Port = 587;
|
||||
// $email->Username = 'fsfe_user';
|
||||
// $email->Password = 'fsfe_pass';
|
||||
// $email->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$email->SetFrom($who.'@fsfe.org', $who_verbose);
|
||||
$email->CharSet = 'UTF-8';
|
||||
$email->Subject = '=?UTF-8?B?'.base64_encode("per diem statement by {$who_verbose} for {$activity_text}").'?=';
|
||||
if ('normal' === $mailopt) {
|
||||
$email->addAddress('finance@lists.fsfe.org');
|
||||
}
|
||||
$email->addAddress($who . "@fsfe.org");
|
||||
|
||||
$email->addAddress($who.'@fsfe.org');
|
||||
|
||||
foreach ($use as $d => $day) { // calculate for each day
|
||||
// set "no" as value for day's variable if empty
|
||||
@@ -194,30 +193,30 @@ foreach ($use as $d => $day) { // calculate for each day
|
||||
$key = $d;
|
||||
}
|
||||
|
||||
if ($use[$d] === 'yes') { // only calculate if checkbox has been activated (day in use)
|
||||
if ($d === 'out' || $d === 'return') { // set amount of € for travel or full day
|
||||
if ('yes' === $use[$d]) { // only calculate if checkbox has been activated (day in use)
|
||||
if ('out' === $d || 'return' === $d) { // set amount of € for travel or full day
|
||||
$reimb_day[$d] = $maxamount_trav; // total max. reimburseable amount for this half day
|
||||
} else {
|
||||
$reimb_day[$d] = $maxamount_full; // total max. reimburseable amount for this full day
|
||||
}
|
||||
|
||||
// date
|
||||
if ($date[$d] === '') {
|
||||
$date[$d] = "Day " . $d;
|
||||
if ('' === $date[$d]) {
|
||||
$date[$d] = 'Day '.$d;
|
||||
}
|
||||
// breakfast
|
||||
if ($break[$d] !== "yes") {
|
||||
if ('yes' !== $break[$d]) {
|
||||
// if meal paid by someone else: total amount for today =
|
||||
// MINUS total possible amount for a FULL day * rate for this meal
|
||||
// no matter whether today is a full or a half day
|
||||
$reimb_day[$d] = $reimb_day[$d] - $maxamount_full * $rate_breakf;
|
||||
}
|
||||
// lunch
|
||||
if ($lunch[$d] !== "yes") {
|
||||
if ('yes' !== $lunch[$d]) {
|
||||
$reimb_day[$d] = $reimb_day[$d] - $maxamount_full * $rate_lunch;
|
||||
}
|
||||
// dinner
|
||||
if ($dinner[$d] !== "yes") {
|
||||
if ('yes' !== $dinner[$d]) {
|
||||
$reimb_day[$d] = $reimb_day[$d] - $maxamount_full * $rate_dinner;
|
||||
}
|
||||
|
||||
@@ -233,42 +232,41 @@ foreach ($use as $d => $day) { // calculate for each day
|
||||
$reimb_day[$d] = number_format($reimb_day[$d], 2, ',', '');
|
||||
|
||||
// Remarks, explanation what has been self-paid
|
||||
$remarks[$d] = "";
|
||||
if ($break[$d] === "yes") {
|
||||
$remarks[$d] .= "breakfast+";
|
||||
$remarks[$d] = '';
|
||||
if ('yes' === $break[$d]) {
|
||||
$remarks[$d] .= 'breakfast+';
|
||||
}
|
||||
if ($lunch[$d] === "yes") {
|
||||
$remarks[$d] .= "lunch+";
|
||||
if ('yes' === $lunch[$d]) {
|
||||
$remarks[$d] .= 'lunch+';
|
||||
}
|
||||
if ($dinner[$d] === "yes") {
|
||||
$remarks[$d] .= "dinner";
|
||||
if ('yes' === $dinner[$d]) {
|
||||
$remarks[$d] .= 'dinner';
|
||||
}
|
||||
if ($break[$d] != "yes" && $lunch[$d] != "yes" && $dinner[$d] != "yes") {
|
||||
$remarks[$d] = "nothing";
|
||||
if ('yes' != $break[$d] && 'yes' != $lunch[$d] && 'yes' != $dinner[$d]) {
|
||||
$remarks[$d] = 'nothing';
|
||||
}
|
||||
if ($break[$d] === "yes" && $lunch[$d] === "yes" && $dinner[$d] === "yes") {
|
||||
$remarks[$d] = "everything";
|
||||
if ('yes' === $break[$d] && 'yes' === $lunch[$d] && 'yes' === $dinner[$d]) {
|
||||
$remarks[$d] = 'everything';
|
||||
}
|
||||
$remarks[$d] = preg_replace("/\+$/", "", $remarks[$d]);
|
||||
$remarks[$d] .= " self-paid";
|
||||
$remarks[$d] = preg_replace('/\+$/', '', $remarks[$d]);
|
||||
$remarks[$d] .= ' self-paid';
|
||||
|
||||
// HTML output for this day
|
||||
$html .= "
|
||||
<tr>
|
||||
<td>$date[$d]</td>
|
||||
<td>$reimb_day[$d]</td>
|
||||
<td>$who_verbose</td>
|
||||
<td>$activity_tag</td>
|
||||
<td>$activity_text</td>
|
||||
<td>$category_id</td>
|
||||
<td>$category_text</td>
|
||||
<td>$event</td>
|
||||
<td>$remarks[$d]</td>
|
||||
<td>{$date[$d]}</td>
|
||||
<td>{$reimb_day[$d]}</td>
|
||||
<td>{$who_verbose}</td>
|
||||
<td>{$activity_tag}</td>
|
||||
<td>{$activity_text}</td>
|
||||
<td>{$category_id}</td>
|
||||
<td>{$category_text}</td>
|
||||
<td>{$event}</td>
|
||||
<td>{$remarks[$d]}</td>
|
||||
</tr>";
|
||||
|
||||
// CSV for this receipt
|
||||
$csv[$key] = array($who_empnumber, $who_verbose, $date[$d], $reimb_day[$d], $who_verbose, $activity_tag, $activity_text, $category_id, $category_text, $event, $remarks[$d], "");
|
||||
|
||||
$csv[$key] = [$who_empnumber, $who_verbose, $date[$d], $reimb_day[$d], $who_verbose, $activity_tag, $activity_text, $category_id, $category_text, $event, $remarks[$d], ''];
|
||||
} // if day is used
|
||||
} // foreach
|
||||
|
||||
@@ -276,13 +274,13 @@ foreach ($use as $d => $day) { // calculate for each day
|
||||
foreach ($csv as $fields) {
|
||||
fputcsv($csvfile, $fields, ';', '"', '"');
|
||||
}
|
||||
$email->addAttachment($csvfile_path, filter_filename($date[$d]."-"."pd" ."-". $who ."-". $activity_tag ."-". $event . ".csv"));
|
||||
$email->addAttachment($csvfile_path, filter_filename($date[$d].'-pd-'.$who.'-'.$activity_tag.'-'.$event.'.csv'));
|
||||
|
||||
// Prepare email body
|
||||
$email_body = "Hi,
|
||||
|
||||
This is a per diem statement by $who_verbose for
|
||||
$activity_tag ($activity_text),
|
||||
This is a per diem statement by {$who_verbose} for
|
||||
{$activity_tag} ({$activity_text}),
|
||||
sent via <https://fsfe.org/internal/pd>.
|
||||
|
||||
Please find the expenses attached.";
|
||||
@@ -291,22 +289,22 @@ Please find the expenses attached.";
|
||||
$reimb_total = number_format($reimb_total, 2, ',', '');
|
||||
|
||||
// Finalise output table
|
||||
$html .= "<tr><td><strong>Total:</strong></td><td><strong>$reimb_total $currency</strong></td>";
|
||||
$html .= "<tr><td><strong>Total:</strong></td><td><strong>{$reimb_total} {$currency}</strong></td>";
|
||||
$html .= "<td colspan='8'></td></tr>";
|
||||
$html .= "</table>";
|
||||
$html .= '</table>';
|
||||
if ($extra) {
|
||||
$html .= "<p>Extra remarks: <br />$extra</p>";
|
||||
$html .= "<p>Extra remarks: <br />{$extra}</p>";
|
||||
|
||||
$email_body .= "
|
||||
|
||||
The sender added the following comment:
|
||||
|
||||
$extra";
|
||||
{$extra}";
|
||||
}
|
||||
|
||||
// Send email, and delete attachments
|
||||
$email->Body = $email_body;
|
||||
if ($mailopt === "normal" || $mailopt === "onlyme") {
|
||||
if ('normal' === $mailopt || 'onlyme' === $mailopt) {
|
||||
$email->send();
|
||||
$html .= $email->ErrorInfo;
|
||||
}
|
||||
|
||||
+179
-179
@@ -2,31 +2,34 @@
|
||||
|
||||
function eval_xml_template($template, $data)
|
||||
{
|
||||
$dir = dirname(__FILE__) . '/../templates';
|
||||
$result = file_get_contents("$dir/$template");
|
||||
$dir = dirname(__FILE__).'/../templates';
|
||||
$result = file_get_contents("{$dir}/{$template}");
|
||||
foreach ($data as $key => $value) {
|
||||
$result = preg_replace("/<tpl name=\"$key\"><\/tpl>/", $value, $result);
|
||||
$result = preg_replace("/<tpl name=\"{$key}\"><\\/tpl>/", $value, $result);
|
||||
}
|
||||
$result = preg_replace("/<tpl name=\"[^\"]*\"><\/tpl>/", '', $result);
|
||||
return $result;
|
||||
|
||||
return preg_replace('/<tpl name="[^"]*"><\/tpl>/', '', $result);
|
||||
}
|
||||
function eval_template($template, $data)
|
||||
{
|
||||
extract($data);
|
||||
$dir = realpath(dirname(__FILE__) . '/../templates');
|
||||
$dir = realpath(dirname(__FILE__).'/../templates');
|
||||
ob_start();
|
||||
include("$dir/$template");
|
||||
|
||||
include "{$dir}/{$template}";
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $result;
|
||||
}
|
||||
function gen_alnum($digits)
|
||||
{
|
||||
$alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
$ret = '';
|
||||
for ($digits; $digits > 0; $digits--) {
|
||||
for ($digits; $digits > 0; --$digits) {
|
||||
$ret .= substr($alphabet, rand(0, 35), 1);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -38,41 +41,41 @@ function relay_donation($orderID)
|
||||
$language = $_POST['language'];
|
||||
$lang = substr($language, 0, 2);
|
||||
|
||||
$PSPID = "40F00871";
|
||||
$TP = "payment-without-bank.html";
|
||||
$acceptURL = "https://fsfe.org/donate/thankyou.$lang.html";
|
||||
$cancelURL = "https://fsfe.org/donate/cancel.$lang.html";
|
||||
$PSPID = '40F00871';
|
||||
$TP = 'payment-without-bank.html';
|
||||
$acceptURL = "https://fsfe.org/donate/thankyou.{$lang}.html";
|
||||
$cancelURL = "https://fsfe.org/donate/cancel.{$lang}.html";
|
||||
|
||||
$salt = "Only4TestingPurposes";
|
||||
$salt = 'Only4TestingPurposes';
|
||||
$shasum = strtoupper(sha1(
|
||||
"ACCEPTURL=$acceptURL$salt" .
|
||||
"AMOUNT=$amount100$salt" .
|
||||
"CANCELURL=$cancelURL$salt" .
|
||||
//"CN=$name$salt".
|
||||
//"COM=Donation$salt".
|
||||
"CURRENCY=EUR$salt" .
|
||||
"EMAIL=$email$salt" .
|
||||
"LANGUAGE=$language$salt" .
|
||||
"ORDERID=$orderID$salt" .
|
||||
"PMLISTTYPE=2$salt" .
|
||||
"PSPID=$PSPID$salt" .
|
||||
"TP=$TP$salt"
|
||||
"ACCEPTURL={$acceptURL}{$salt}"
|
||||
."AMOUNT={$amount100}{$salt}"
|
||||
."CANCELURL={$cancelURL}{$salt}"
|
||||
// "CN=$name$salt".
|
||||
// "COM=Donation$salt".
|
||||
."CURRENCY=EUR{$salt}"
|
||||
."EMAIL={$email}{$salt}"
|
||||
."LANGUAGE={$language}{$salt}"
|
||||
."ORDERID={$orderID}{$salt}"
|
||||
."PMLISTTYPE=2{$salt}"
|
||||
."PSPID={$PSPID}{$salt}"
|
||||
."TP={$TP}{$salt}"
|
||||
));
|
||||
|
||||
echo eval_xml_template('concardis_relay.en.html', array(
|
||||
'PSPID' => '<input type="hidden" name="PSPID" value="' . $PSPID . '">',
|
||||
'orderID' => '<input type="hidden" name="orderID" value="' . $orderID . '">',
|
||||
'amount' => '<input type="hidden" name="amount" value="' . $amount100 . '">',
|
||||
//'currency' => '<input type="hidden" name="currency" value="EUR">',
|
||||
'language' => '<input type="hidden" name="language" value="' . $language . '">',
|
||||
//'CN' => '<input type="hidden" name="CN" value="'.$name.'">',
|
||||
'EMAIL' => '<input type="hidden" name="EMAIL" value="' . $email . '">',
|
||||
'TP' => '<input type="hidden" name="TP" value="' . $TP . '">',
|
||||
//'PMListType' => '<input type="hidden" name="PMListType" value="2">',
|
||||
'accepturl' => '<input type="hidden" name="accepturl" value="' . $acceptURL . '">',
|
||||
'cancelurl' => '<input type="hidden" name="cancelurl" value="' . $cancelURL . '">',
|
||||
'SHASign' => '<input type="hidden" name="SHASign" value="' . $shasum . '">'
|
||||
));
|
||||
echo eval_xml_template('concardis_relay.en.html', [
|
||||
'PSPID' => '<input type="hidden" name="PSPID" value="'.$PSPID.'">',
|
||||
'orderID' => '<input type="hidden" name="orderID" value="'.$orderID.'">',
|
||||
'amount' => '<input type="hidden" name="amount" value="'.$amount100.'">',
|
||||
// 'currency' => '<input type="hidden" name="currency" value="EUR">',
|
||||
'language' => '<input type="hidden" name="language" value="'.$language.'">',
|
||||
// 'CN' => '<input type="hidden" name="CN" value="'.$name.'">',
|
||||
'EMAIL' => '<input type="hidden" name="EMAIL" value="'.$email.'">',
|
||||
'TP' => '<input type="hidden" name="TP" value="'.$TP.'">',
|
||||
// 'PMListType' => '<input type="hidden" name="PMListType" value="2">',
|
||||
'accepturl' => '<input type="hidden" name="accepturl" value="'.$acceptURL.'">',
|
||||
'cancelurl' => '<input type="hidden" name="cancelurl" value="'.$cancelURL.'">',
|
||||
'SHASign' => '<input type="hidden" name="SHASign" value="'.$shasum.'">',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,14 +84,13 @@ function relay_donation($orderID)
|
||||
* Sends the script into the background to
|
||||
* handle the request asynchronously.
|
||||
*
|
||||
* @param array $data
|
||||
* @see mail-signup.php
|
||||
*/
|
||||
function mail_signup(array $data)
|
||||
{
|
||||
$cmd = sprintf(
|
||||
'php %s %s > /dev/null &',
|
||||
__DIR__ . '/mail-signup.php',
|
||||
__DIR__.'/mail-signup.php',
|
||||
escapeshellarg(json_encode($data))
|
||||
);
|
||||
exec($cmd);
|
||||
@@ -96,205 +98,203 @@ function mail_signup(array $data)
|
||||
|
||||
$lang = $_POST['language'];
|
||||
|
||||
# Sanity checks (*very* sloppy input validation)
|
||||
// Sanity checks (*very* sloppy input validation)
|
||||
if (
|
||||
empty($_POST['lastname']) ||
|
||||
empty($_POST['mail']) ||
|
||||
stripos($_POST['mail'], 'example') ||
|
||||
stripos($_POST['mail'], '@@') ||
|
||||
empty($_POST['street']) ||
|
||||
empty($_POST['zip']) ||
|
||||
empty($_POST['city']) ||
|
||||
empty($_POST['country']) ||
|
||||
empty($_POST['packagetype']) ||
|
||||
!empty($_POST['address'])
|
||||
empty($_POST['lastname'])
|
||||
|| empty($_POST['mail'])
|
||||
|| stripos($_POST['mail'], 'example')
|
||||
|| stripos($_POST['mail'], '@@')
|
||||
|| empty($_POST['street'])
|
||||
|| empty($_POST['zip'])
|
||||
|| empty($_POST['city'])
|
||||
|| empty($_POST['country'])
|
||||
|| empty($_POST['packagetype'])
|
||||
|| !empty($_POST['address'])
|
||||
) {
|
||||
header("Location: https://fsfe.org/contribute/spreadtheword-ordererror.{$lang}.html");
|
||||
|
||||
header("Location: https://fsfe.org/contribute/spreadtheword-ordererror.$lang.html");
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
# Without this, escapeshellarg() will eat non-ASCII characters.
|
||||
setlocale(LC_CTYPE, "en_US.UTF-8");
|
||||
// Without this, escapeshellarg() will eat non-ASCII characters.
|
||||
setlocale(LC_CTYPE, 'en_US.UTF-8');
|
||||
|
||||
# $_POST["country"] has values like "DE|Germany", so split this string
|
||||
$countrycode = explode('|', $_POST["country"])[0];
|
||||
$countryname = explode('|', $_POST["country"])[1];
|
||||
// $_POST["country"] has values like "DE|Germany", so split this string
|
||||
$countrycode = explode('|', $_POST['country'])[0];
|
||||
$countryname = explode('|', $_POST['country'])[1];
|
||||
|
||||
$subject = "Promotion material order";
|
||||
$msg_to_staff = "Please send me promotional material:\n" .
|
||||
"First Name: {$_POST['firstname']}\n" .
|
||||
"Last Name: {$_POST['lastname']}\n" .
|
||||
"EMail: {$_POST['mail']}\n" .
|
||||
"\n" .
|
||||
"Address:\n" .
|
||||
"{$_POST['firstname']} " . "{$_POST['lastname']}\n";
|
||||
$subject = 'Promotion material order';
|
||||
$msg_to_staff = "Please send me promotional material:\n"
|
||||
."First Name: {$_POST['firstname']}\n"
|
||||
."Last Name: {$_POST['lastname']}\n"
|
||||
."EMail: {$_POST['mail']}\n"
|
||||
."\n"
|
||||
."Address:\n"
|
||||
."{$_POST['firstname']} {$_POST['lastname']}\n";
|
||||
|
||||
if (!empty($_POST['org'])) {
|
||||
$msg_to_staff .= "{$_POST['org']}\n";
|
||||
}
|
||||
$msg_to_staff .= "{$_POST['street']}\n" .
|
||||
"{$_POST['zip']} " . "{$_POST['city']}\n" .
|
||||
"{$countryname}\n" .
|
||||
"\n" .
|
||||
"Specifics of the Order:\n";
|
||||
# Default or custom package?
|
||||
if ($_POST['packagetype'] == 'basic_sticker') {
|
||||
$msg_to_staff .= "{$_POST['street']}\n"
|
||||
."{$_POST['zip']} {$_POST['city']}\n"
|
||||
."{$countryname}\n"
|
||||
."\n"
|
||||
."Specifics of the Order:\n";
|
||||
// Default or custom package?
|
||||
if ('basic_sticker' == $_POST['packagetype']) {
|
||||
$msg_to_staff .= "My Laptop: Basic Set of Stickers.\n";
|
||||
} elseif ($_POST['packagetype'] == 'basicpostcard') {
|
||||
} elseif ('basicpostcard' == $_POST['packagetype']) {
|
||||
$msg_to_staff .= "Postcards and Stickers.\n";
|
||||
} elseif ($_POST['packagetype'] == 'basicsticker') {
|
||||
} elseif ('basicsticker' == $_POST['packagetype']) {
|
||||
$msg_to_staff .= "Small package with stickers.\n";
|
||||
} elseif ($_POST['packagetype'] == 'morestickers') {
|
||||
} elseif ('morestickers' == $_POST['packagetype']) {
|
||||
$msg_to_staff .= "Stickers for me and my friend: Twice the amount of our most popular stickers.\n";
|
||||
} elseif ($_POST['packagetype'] == 'standard') {
|
||||
} elseif ('standard' == $_POST['packagetype']) {
|
||||
$msg_to_staff .= "Standard Package.\n";
|
||||
} else {
|
||||
$msg_to_staff .= "Custom package:\n" .
|
||||
"{$_POST['specifics']}\n";
|
||||
$msg_to_staff .= "Custom package:\n"
|
||||
."{$_POST['specifics']}\n";
|
||||
}
|
||||
$languages = implode(',', $_POST['languages']);
|
||||
$msg_to_staff .= "\n" .
|
||||
"Preferred language(s) (if available):\n" .
|
||||
"{$languages}\n" .
|
||||
"\n" .
|
||||
"The material is going to be used for:\n" .
|
||||
"{$_POST['usage']}\n" .
|
||||
"\n" .
|
||||
"Comments:\n" .
|
||||
"{$_POST['comment']}\n";
|
||||
$msg_to_staff .= "\n"
|
||||
."Preferred language(s) (if available):\n"
|
||||
."{$languages}\n"
|
||||
."\n"
|
||||
."The material is going to be used for:\n"
|
||||
."{$_POST['usage']}\n"
|
||||
."\n"
|
||||
."Comments:\n"
|
||||
."{$_POST['comment']}\n";
|
||||
|
||||
$_POST['donationID'] = "";
|
||||
$_POST['donationID'] = '';
|
||||
if (isset($_POST['donate']) && ($_POST['donate'] > 0)) {
|
||||
$_POST['donationID'] = "DAFSPCK" . gen_alnum(5);
|
||||
$subject .= ": " . $_POST['donationID'];
|
||||
$msg_to_staff .= "\n\nThe orderer choose to make a Donation of {$_POST['donate']} Euro.\n" .
|
||||
"Please do not assume that this donation has been made until you receive\n" .
|
||||
"confirmation from Concardis for the order: {$_POST['donationID']}";
|
||||
$_POST['donationID'] = 'DAFSPCK'.gen_alnum(5);
|
||||
$subject .= ': '.$_POST['donationID'];
|
||||
$msg_to_staff .= "\n\nThe orderer choose to make a Donation of {$_POST['donate']} Euro.\n"
|
||||
."Please do not assume that this donation has been made until you receive\n"
|
||||
."confirmation from Concardis for the order: {$_POST['donationID']}";
|
||||
}
|
||||
|
||||
# Generate letter to be sent along with the material
|
||||
$odtfill = $_SERVER["DOCUMENT_ROOT"] . "/cgi-bin/odtfill";
|
||||
$template = $_SERVER["DOCUMENT_ROOT"] . "/templates/promotionorder.odt";
|
||||
$outfile = "/tmp/promotionorder.odt";
|
||||
$name = $_POST['firstname'] . " " . $_POST['lastname'];
|
||||
$address = "";
|
||||
// Generate letter to be sent along with the material
|
||||
$odtfill = $_SERVER['DOCUMENT_ROOT'].'/cgi-bin/odtfill';
|
||||
$template = $_SERVER['DOCUMENT_ROOT'].'/templates/promotionorder.odt';
|
||||
$outfile = '/tmp/promotionorder.odt';
|
||||
$name = $_POST['firstname'].' '.$_POST['lastname'];
|
||||
$address = '';
|
||||
if (!empty($_POST['org'])) {
|
||||
$address .= $_POST['org'] . "\\n";
|
||||
$address .= $_POST['org'].'\n';
|
||||
}
|
||||
$address .= $_POST['street'] . "\\n" .
|
||||
$_POST['zip'] . " " . $_POST['city'] . "\\n" .
|
||||
$countryname;
|
||||
$address .= $_POST['street'].'\n'
|
||||
.$_POST['zip'].' '.$_POST['city'].'\n'
|
||||
.$countryname;
|
||||
$cmd = sprintf(
|
||||
'%s %s %s %s %s %s',
|
||||
$odtfill,
|
||||
$template,
|
||||
$outfile,
|
||||
'Name=' . escapeshellarg($name),
|
||||
'Address=' . escapeshellarg($address),
|
||||
'Name=' . escapeshellarg($name)
|
||||
'Name='.escapeshellarg($name),
|
||||
'Address='.escapeshellarg($address),
|
||||
'Name='.escapeshellarg($name)
|
||||
);
|
||||
shell_exec($cmd);
|
||||
|
||||
# Make subscriptions to newsletter/community mails
|
||||
// Make subscriptions to newsletter/community mails
|
||||
$subcd = isset($_POST['subcd']) ? $_POST['subcd'] : false;
|
||||
$subnl = isset($_POST['subnl']) ? $_POST['subnl'] : false;
|
||||
if ($subcd == "y" or $subnl == "y") {
|
||||
$signupdata = array(
|
||||
'name' => $_POST['firstname'] . " " . $_POST['lastname'],
|
||||
'email1' => $_POST['mail'],
|
||||
'address' => $_POST['street'],
|
||||
'zip' => $_POST['zip'],
|
||||
'city' => $_POST['city'],
|
||||
'langugage' => $_POST['language'],
|
||||
'country' => $countrycode
|
||||
);
|
||||
if ($subcd == "y") {
|
||||
if ('y' == $subcd or 'y' == $subnl) {
|
||||
$signupdata = [
|
||||
'name' => $_POST['firstname'].' '.$_POST['lastname'],
|
||||
'email1' => $_POST['mail'],
|
||||
'address' => $_POST['street'],
|
||||
'zip' => $_POST['zip'],
|
||||
'city' => $_POST['city'],
|
||||
'langugage' => $_POST['language'],
|
||||
'country' => $countrycode,
|
||||
];
|
||||
if ('y' == $subcd) {
|
||||
$signupdata['wants_info'] = '1';
|
||||
}
|
||||
if ($subnl == "y") {
|
||||
if ('y' == $subnl) {
|
||||
$signupdata['wants_newsletter_info'] = '1';
|
||||
}
|
||||
mail_signup($signupdata);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'name' => $_POST['firstname'] . " " . $_POST['lastname'],
|
||||
'donationID' => $_POST['donationID'],
|
||||
'donate' => $_POST['donate'],
|
||||
'lang' => $lang,
|
||||
'name' => $_POST['firstname'].' '.$_POST['lastname'],
|
||||
'donationID' => $_POST['donationID'],
|
||||
'donate' => $_POST['donate'],
|
||||
'lang' => $lang,
|
||||
];
|
||||
$msg_to_customer = eval_template('promoorder/promoorder.php', $data);
|
||||
|
||||
/**
|
||||
* Create a new ticket in the FreeScout system
|
||||
* Create a new ticket in the FreeScout system.
|
||||
*/
|
||||
$url = "https://helpdesk.fsfe.org/api/conversations";
|
||||
$url = 'https://helpdesk.fsfe.org/api/conversations';
|
||||
$apikey = getenv('FREESCOUT_API_KEY');
|
||||
$jsondata = [
|
||||
"type" => "email",
|
||||
"mailboxId" => 7, # This is the Merchandise Mailbox
|
||||
"subject" => $subject,
|
||||
"customer" => [
|
||||
"email" => $_POST['mail']
|
||||
],
|
||||
"threads" => [
|
||||
[
|
||||
"text" => $msg_to_staff,
|
||||
"type" => "customer",
|
||||
"customer" => [
|
||||
"email" => $_POST['mail'],
|
||||
"firstName" => $_POST['firstname'],
|
||||
"lastName" => $_POST['lastname'],
|
||||
],
|
||||
"attachments" => [
|
||||
[
|
||||
"fileName" => "letter.odt",
|
||||
"mimeType" => "application/vnd.oasis.opendocument.text",
|
||||
"data" => base64_encode(file_get_contents($outfile))
|
||||
]
|
||||
]
|
||||
'type' => 'email',
|
||||
'mailboxId' => 7, // This is the Merchandise Mailbox
|
||||
'subject' => $subject,
|
||||
'customer' => [
|
||||
'email' => $_POST['mail'],
|
||||
],
|
||||
'threads' => [
|
||||
[
|
||||
'text' => $msg_to_staff,
|
||||
'type' => 'customer',
|
||||
'customer' => [
|
||||
'email' => $_POST['mail'],
|
||||
'firstName' => $_POST['firstname'],
|
||||
'lastName' => $_POST['lastname'],
|
||||
],
|
||||
'attachments' => [
|
||||
[
|
||||
'fileName' => 'letter.odt',
|
||||
'mimeType' => 'application/vnd.oasis.opendocument.text',
|
||||
'data' => base64_encode(file_get_contents($outfile)),
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'text' => $msg_to_customer,
|
||||
'type' => 'message',
|
||||
'user' => 6530,
|
||||
],
|
||||
],
|
||||
'imported' => false,
|
||||
'assignTo' => 6584,
|
||||
'status' => 'active',
|
||||
'customFields' => [
|
||||
[
|
||||
'id' => 4, // Order ID Custom Field
|
||||
'value' => $_POST['donationID'] ?? '', // Donation ID
|
||||
],
|
||||
],
|
||||
[
|
||||
"text" => $msg_to_customer,
|
||||
"type" => "message",
|
||||
"user" => 6530,
|
||||
]
|
||||
],
|
||||
"imported" => false,
|
||||
"assignTo" => 6584,
|
||||
"status" => "active",
|
||||
"customFields" => [
|
||||
[
|
||||
"id" => 4, # Order ID Custom Field
|
||||
"value" => $_POST['donationID'] ?? "" # Donation ID
|
||||
]
|
||||
]
|
||||
];
|
||||
$jsonDataEncoded = json_encode($jsondata);
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => $jsonDataEncoded,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($jsonDataEncoded),
|
||||
"X-FreeScout-API-Key: " . $apikey
|
||||
],
|
||||
CURLOPT_USERAGENT => 'FSFE promotion.php'
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => $jsonDataEncoded,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: '.strlen($jsonDataEncoded),
|
||||
'X-FreeScout-API-Key: '.$apikey,
|
||||
],
|
||||
CURLOPT_USERAGENT => 'FSFE promotion.php',
|
||||
]);
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
/**
|
||||
* Only process donations starting from 10 euro.
|
||||
*/
|
||||
// Only process donations starting from 10 euro.
|
||||
if (isset($_POST['donate']) && ((int) $_POST['donate']) >= 5) {
|
||||
relay_donation($_POST['donationID']);
|
||||
} else {
|
||||
// DEBUG: Comment out next line to be able to see errors and printed info
|
||||
header("Location: https://fsfe.org/contribute/spreadtheword-orderthanks.$lang.html");
|
||||
header("Location: https://fsfe.org/contribute/spreadtheword-orderthanks.{$lang}.html");
|
||||
}
|
||||
|
||||
+226
-208
File diff suppressed because it is too large
Load Diff
+109
-109
@@ -1,34 +1,34 @@
|
||||
<?php
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
|
||||
require 'PHPMailer/Exception.php';
|
||||
|
||||
require 'PHPMailer/PHPMailer.php';
|
||||
|
||||
require 'PHPMailer/SMTP.php';
|
||||
|
||||
$html = ''; // create empty variable
|
||||
$csv = array(array("Employee number", "Employee name", "Date", "Amount (EUR)", "Recipient name", "Activity Tag", "Activity Text", "Category ID", "Category Text", "Event", "Description", "Receipt number")); // create array for CSV
|
||||
$csv = [['Employee number', 'Employee name', 'Date', 'Amount (EUR)', 'Recipient name', 'Activity Tag', 'Activity Text', 'Category ID', 'Category Text', 'Event', 'Description', 'Receipt number']]; // create array for CSV
|
||||
$csvfile = tmpfile();
|
||||
$csvfile_path = stream_get_meta_data($csvfile)['uri'];
|
||||
|
||||
$who = isset($_POST["who"]) ? $_POST["who"] : false;
|
||||
$type = isset($_POST["type"]) ? $_POST["type"] : false;
|
||||
$rc_month = isset($_POST["rc_month"]) ? $_POST["rc_month"] : false;
|
||||
$rc_year = isset($_POST["rc_year"]) ? $_POST["rc_year"] : false;
|
||||
$cc_month = isset($_POST["cc_month"]) ? $_POST["cc_month"] : false;
|
||||
$cc_year = isset($_POST["cc_year"]) ? $_POST["cc_year"] : false;
|
||||
$entry = isset($_POST["entry"]) ? $_POST["entry"] : false; // will become $date in loop
|
||||
$amount = isset($_POST["amount"]) ? $_POST["amount"] : false;
|
||||
$recipient = isset($_POST["recipient"]) ? $_POST["recipient"] : false;
|
||||
$activity = isset($_POST["activity"]) ? $_POST["activity"] : false;
|
||||
$category = isset($_POST["category"]) ? $_POST["category"] : false;
|
||||
$receipt = isset($_POST["receipt"]) ? $_POST["receipt"] : false;
|
||||
$description = isset($_POST["description"]) ? $_POST["description"] : false;
|
||||
$event = isset($_POST["event"]) ? $_POST["event"] : false;
|
||||
$extra = isset($_POST["extra"]) ? $_POST["extra"] : false;
|
||||
$mailopt = isset($_POST["mailopt"]) ? $_POST["mailopt"] : false;
|
||||
$who = isset($_POST['who']) ? $_POST['who'] : false;
|
||||
$type = isset($_POST['type']) ? $_POST['type'] : false;
|
||||
$rc_month = isset($_POST['rc_month']) ? $_POST['rc_month'] : false;
|
||||
$rc_year = isset($_POST['rc_year']) ? $_POST['rc_year'] : false;
|
||||
$cc_month = isset($_POST['cc_month']) ? $_POST['cc_month'] : false;
|
||||
$cc_year = isset($_POST['cc_year']) ? $_POST['cc_year'] : false;
|
||||
$entry = isset($_POST['entry']) ? $_POST['entry'] : false; // will become $date in loop
|
||||
$amount = isset($_POST['amount']) ? $_POST['amount'] : false;
|
||||
$recipient = isset($_POST['recipient']) ? $_POST['recipient'] : false;
|
||||
$activity = isset($_POST['activity']) ? $_POST['activity'] : false;
|
||||
$category = isset($_POST['category']) ? $_POST['category'] : false;
|
||||
$receipt = isset($_POST['receipt']) ? $_POST['receipt'] : false;
|
||||
$description = isset($_POST['description']) ? $_POST['description'] : false;
|
||||
$event = isset($_POST['event']) ? $_POST['event'] : false;
|
||||
$extra = isset($_POST['extra']) ? $_POST['extra'] : false;
|
||||
$mailopt = isset($_POST['mailopt']) ? $_POST['mailopt'] : false;
|
||||
|
||||
// create empty arrays for uploaded file
|
||||
$receipt_dest = [];
|
||||
@@ -38,15 +38,15 @@ $who_verbose = explode('||', $who)[0];
|
||||
$who_empnumber = explode('||', $who)[2];
|
||||
$who = explode('||', $who)[1];
|
||||
|
||||
|
||||
// FUNCTIONS
|
||||
function errexit($msg)
|
||||
{
|
||||
exit("Error: " . $msg . "<br/><br/>To avoid losing your data, press the back button in your browser");
|
||||
exit('Error: '.$msg.'<br/><br/>To avoid losing your data, press the back button in your browser');
|
||||
}
|
||||
function replace_page($temp, $content)
|
||||
{
|
||||
$vars = array(':RESULT:' => $content);
|
||||
$vars = [':RESULT:' => $content];
|
||||
|
||||
return str_replace(array_keys($vars), $vars, $temp);
|
||||
}
|
||||
/* Snippet Begin:
|
||||
@@ -58,7 +58,7 @@ function filter_filename($filename, $beautify = true)
|
||||
// sanitize filename
|
||||
$filename = preg_replace(
|
||||
'~
|
||||
[<>:"/\\|?*]| # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
|
||||
[<>:"/\\\|?*]| # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
|
||||
[\x00-\x1F]| # control characters http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
|
||||
[\x7F\xA0\xAD]| # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN
|
||||
[#\[\]@!$&\'()+,;=]| # URI reserved https://tools.ietf.org/html/rfc3986#section-2.2
|
||||
@@ -75,58 +75,58 @@ function filter_filename($filename, $beautify = true)
|
||||
}
|
||||
// maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$filename = mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)) . ($ext ? '.' . $ext : '');
|
||||
return $filename;
|
||||
|
||||
return mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)).($ext ? '.'.$ext : '');
|
||||
}
|
||||
function beautify_filename($filename)
|
||||
{
|
||||
// reduce consecutive characters
|
||||
$filename = preg_replace(array(
|
||||
// "file name.zip" becomes "file-name.zip"
|
||||
'/ +/',
|
||||
// "file___name.zip" becomes "file-name.zip"
|
||||
'/_+/',
|
||||
// "file---name.zip" becomes "file-name.zip"
|
||||
'/-+/'
|
||||
), '-', $filename);
|
||||
$filename = preg_replace(array(
|
||||
// "file--.--.-.--name.zip" becomes "file.name.zip"
|
||||
'/-*\.-*/',
|
||||
// "file...name..zip" becomes "file.name.zip"
|
||||
'/\.{2,}/'
|
||||
), '.', $filename);
|
||||
$filename = preg_replace([
|
||||
// "file name.zip" becomes "file-name.zip"
|
||||
'/ +/',
|
||||
// "file___name.zip" becomes "file-name.zip"
|
||||
'/_+/',
|
||||
// "file---name.zip" becomes "file-name.zip"
|
||||
'/-+/',
|
||||
], '-', $filename);
|
||||
$filename = preg_replace([
|
||||
// "file--.--.-.--name.zip" becomes "file.name.zip"
|
||||
'/-*\.-*/',
|
||||
// "file...name..zip" becomes "file.name.zip"
|
||||
'/\.{2,}/',
|
||||
], '.', $filename);
|
||||
// lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625
|
||||
$filename = mb_strtolower($filename, mb_detect_encoding($filename));
|
||||
|
||||
// ".file-name.-" becomes "file-name"
|
||||
$filename = trim($filename, '.-');
|
||||
return $filename;
|
||||
return trim($filename, '.-');
|
||||
}
|
||||
/* Snippet End */
|
||||
// Snippet End
|
||||
|
||||
// Sanity checks for parameters, and setting variables depending on type
|
||||
if ($type == "rc") {
|
||||
if (! $rc_month || ! $rc_year) {
|
||||
errexit("You must provide month and year of the RC");
|
||||
if ('rc' == $type) {
|
||||
if (!$rc_month || !$rc_year) {
|
||||
errexit('You must provide month and year of the RC');
|
||||
}
|
||||
$type_verbose = "Reimbursement Claim";
|
||||
$type_date = "$rc_year-$rc_month";
|
||||
} elseif ($type == "cc") {
|
||||
if (! $cc_month || ! $cc_year) {
|
||||
errexit("You must provide quarter and year of the CC statement");
|
||||
$type_verbose = 'Reimbursement Claim';
|
||||
$type_date = "{$rc_year}-{$rc_month}";
|
||||
} elseif ('cc' == $type) {
|
||||
if (!$cc_month || !$cc_year) {
|
||||
errexit('You must provide quarter and year of the CC statement');
|
||||
}
|
||||
$type_verbose = "Credit Card Statement";
|
||||
$type_date = "$cc_year-$cc_month";
|
||||
$type_verbose = 'Credit Card Statement';
|
||||
$type_date = "{$cc_year}-{$cc_month}";
|
||||
} else {
|
||||
errexit("You must provide a reimbursement type");
|
||||
errexit('You must provide a reimbursement type');
|
||||
}
|
||||
|
||||
// Prepare output table
|
||||
if ($mailopt === "onlyme") {
|
||||
$html .= "<p><strong>ATTENTION: The email has only been sent to you, not to the financial team!</strong></p>";
|
||||
} elseif ($mailopt === "none") {
|
||||
$html .= "<p><strong>ATTENTION: You have configured to not send any email!</strong></p>";
|
||||
if ('onlyme' === $mailopt) {
|
||||
$html .= '<p><strong>ATTENTION: The email has only been sent to you, not to the financial team!</strong></p>';
|
||||
} elseif ('none' === $mailopt) {
|
||||
$html .= '<p><strong>ATTENTION: You have configured to not send any email!</strong></p>';
|
||||
}
|
||||
$html .= "<p>This <strong>$type_verbose</strong> is made by <strong>$who_verbose</strong>.</p>
|
||||
$html .= "<p>This <strong>{$type_verbose}</strong> is made by <strong>{$who_verbose}</strong>.</p>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
@@ -145,23 +145,23 @@ $html .= "<p>This <strong>$type_verbose</strong> is made by <strong>$who_verbose
|
||||
// Prepare email
|
||||
$email = new PHPMailer();
|
||||
$email->isSMTP();
|
||||
$email->Host = "mail.fsfe.org";
|
||||
$email->Host = 'mail.fsfe.org';
|
||||
// Settings on server
|
||||
$email->SMTPAuth = false;
|
||||
$email->Port = 25;
|
||||
$email->SMTPAuth = false;
|
||||
$email->Port = 25;
|
||||
// Settings for local debug
|
||||
//$email->SMTPAuth = true;
|
||||
//$email->Port = 587;
|
||||
//$email->Username = 'fsfe_user';
|
||||
//$email->Password = 'fsfe_pass';
|
||||
//$email->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$email->SetFrom($who . "@fsfe.org", $who_verbose);
|
||||
$email->CharSet = "UTF-8";
|
||||
$email->Subject = "=?UTF-8?B?" . base64_encode("$type_verbose for $type_date by $who_verbose") . "?=";
|
||||
if ($mailopt === "normal") {
|
||||
$email->addAddress("finance@lists.fsfe.org");
|
||||
// $email->SMTPAuth = true;
|
||||
// $email->Port = 587;
|
||||
// $email->Username = 'fsfe_user';
|
||||
// $email->Password = 'fsfe_pass';
|
||||
// $email->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$email->SetFrom($who.'@fsfe.org', $who_verbose);
|
||||
$email->CharSet = 'UTF-8';
|
||||
$email->Subject = '=?UTF-8?B?'.base64_encode("{$type_verbose} for {$type_date} by {$who_verbose}").'?=';
|
||||
if ('normal' === $mailopt) {
|
||||
$email->addAddress('finance@lists.fsfe.org');
|
||||
}
|
||||
$email->addAddress($who . "@fsfe.org");
|
||||
$email->addAddress($who.'@fsfe.org');
|
||||
|
||||
foreach ($entry as $key => $date) { // run over each row
|
||||
// Get basic variable for each row
|
||||
@@ -173,67 +173,67 @@ foreach ($entry as $key => $date) { // run over each row
|
||||
* rename: the format we want each file to have
|
||||
* dest: the temporary but known location of the file
|
||||
*/
|
||||
$receipt_tmp = $_FILES["receipt"]["tmp_name"][$key];
|
||||
$receipt_error = $_FILES["receipt"]["error"][$key];
|
||||
$receipt_name = basename($_FILES["receipt"]["name"][$key]);
|
||||
$receipt_size = $_FILES["receipt"]["size"][$key];
|
||||
$receipt_tmp = $_FILES['receipt']['tmp_name'][$key];
|
||||
$receipt_error = $_FILES['receipt']['error'][$key];
|
||||
$receipt_name = basename($_FILES['receipt']['name'][$key]);
|
||||
$receipt_size = $_FILES['receipt']['size'][$key];
|
||||
$key1 = $key + 1;
|
||||
$receipt_no = sprintf('%02d', $key1);
|
||||
$activity_tag[$key] = explode("||", $activity[$key])[0];
|
||||
$activity_text[$key] = explode("||", $activity[$key])[1];
|
||||
$category_id[$key] = explode(":", $category[$key])[0];
|
||||
$category_text[$key] = explode(":", $category[$key])[1];
|
||||
$activity_tag[$key] = explode('||', $activity[$key])[0];
|
||||
$activity_text[$key] = explode('||', $activity[$key])[1];
|
||||
$category_id[$key] = explode(':', $category[$key])[0];
|
||||
$category_text[$key] = explode(':', $category[$key])[1];
|
||||
$event[$key] = $event[$key];
|
||||
|
||||
// Sanity checks for receipt: upload, size, mime type
|
||||
if (! $receipt_tmp) {
|
||||
errexit("Something with $receipt_name went wrong, it has not been uploaded.");
|
||||
if (!$receipt_tmp) {
|
||||
errexit("Something with {$receipt_name} went wrong, it has not been uploaded.");
|
||||
}
|
||||
if ($receipt_size > 2097152) {
|
||||
errexit("File size of $receipt_name must not be larger than 2MB");
|
||||
errexit("File size of {$receipt_name} must not be larger than 2MB");
|
||||
}
|
||||
$receipt_mime = mime_content_type($receipt_tmp);
|
||||
if (! in_array($receipt_mime, array('image/jpeg', 'image/png', 'application/pdf'))) {
|
||||
errexit("Only PDF, JPG and PNG allowed. $receipt_name has $receipt_mime");
|
||||
if (!in_array($receipt_mime, ['image/jpeg', 'image/png', 'application/pdf'])) {
|
||||
errexit("Only PDF, JPG and PNG allowed. {$receipt_name} has {$receipt_mime}");
|
||||
}
|
||||
|
||||
// Set name and temporary destination for attached receipt
|
||||
$receipt_ext = pathinfo($receipt_name)['extension'];
|
||||
$receipt_rename = filter_filename($type_date ."-". $type ."-". $who ."-receipt-". $receipt_no ."-". $activity_tag[$key] .".". "$receipt_ext");
|
||||
$receipt_dest[$key] = "/tmp/" . $receipt_rename;
|
||||
$receipt_rename = filter_filename($type_date.'-'.$type.'-'.$who.'-receipt-'.$receipt_no.'-'.$activity_tag[$key].'.'."{$receipt_ext}");
|
||||
$receipt_dest[$key] = '/tmp/'.$receipt_rename;
|
||||
|
||||
// Try to move file to temporary destination
|
||||
if ($receipt_error == UPLOAD_ERR_OK) {
|
||||
if (! move_uploaded_file($receipt_tmp, $receipt_dest[$key])) {
|
||||
if (UPLOAD_ERR_OK == $receipt_error) {
|
||||
if (!move_uploaded_file($receipt_tmp, $receipt_dest[$key])) {
|
||||
errexit("Could not move uploaded file '".$receipt_tmp."' to '".$receipt_dest."'<br/>\n");
|
||||
}
|
||||
} else {
|
||||
errexit("Upload error. [".$receipt_error."] on file '".$receipt_name."'<br/>\n");
|
||||
errexit('Upload error. ['.$receipt_error."] on file '".$receipt_name."'<br/>\n");
|
||||
}
|
||||
|
||||
// Remove "-" when remark empty
|
||||
if ($description[$key] === "-") {
|
||||
$description[$key] = "";
|
||||
if ('-' === $description[$key]) {
|
||||
$description[$key] = '';
|
||||
}
|
||||
|
||||
// HTML output for this receipt
|
||||
$html .= "
|
||||
<tr>
|
||||
<td>$date</td>
|
||||
<td>$amount[$key]</td>
|
||||
<td>$recipient[$key]</td>
|
||||
<td>$activity_tag[$key]</td>
|
||||
<td>$activity_text[$key]</td>
|
||||
<td>$category_id[$key]</td>
|
||||
<td>$category_text[$key]</td>
|
||||
<td>$event[$key]</td>
|
||||
<td>$description[$key]</td>
|
||||
<td>$receipt_name</td>
|
||||
<td>{$date}</td>
|
||||
<td>{$amount[$key]}</td>
|
||||
<td>{$recipient[$key]}</td>
|
||||
<td>{$activity_tag[$key]}</td>
|
||||
<td>{$activity_text[$key]}</td>
|
||||
<td>{$category_id[$key]}</td>
|
||||
<td>{$category_text[$key]}</td>
|
||||
<td>{$event[$key]}</td>
|
||||
<td>{$description[$key]}</td>
|
||||
<td>{$receipt_name}</td>
|
||||
<td></td>
|
||||
</tr>";
|
||||
|
||||
// CSV for this receipt
|
||||
$csv[$receipt_no] = array($who_empnumber, $who_verbose, $date, $amount[$key], $recipient[$key], $activity_tag[$key], $activity_text[$key], $category_id[$key], $category_text[$key], $event[$key], $description[$key], $receipt_no);
|
||||
$csv[$receipt_no] = [$who_empnumber, $who_verbose, $date, $amount[$key], $recipient[$key], $activity_tag[$key], $activity_text[$key], $category_id[$key], $category_text[$key], $event[$key], $description[$key], $receipt_no];
|
||||
|
||||
// Add receipt as email attachment
|
||||
$email->addAttachment($receipt_dest[$key], basename($receipt_dest[$key]));
|
||||
@@ -243,31 +243,31 @@ foreach ($entry as $key => $date) { // run over each row
|
||||
foreach ($csv as $fields) {
|
||||
fputcsv($csvfile, $fields, ';', '"', '"');
|
||||
}
|
||||
$email->addAttachment($csvfile_path, filter_filename($type_date ."-". $type ."-". $who . ".csv"));
|
||||
$email->addAttachment($csvfile_path, filter_filename($type_date.'-'.$type.'-'.$who.'.csv'));
|
||||
|
||||
// Prepare email body
|
||||
$email_body = "Hi,
|
||||
|
||||
This is a $type_verbose for $type_date by $who_verbose,
|
||||
This is a {$type_verbose} for {$type_date} by {$who_verbose},
|
||||
sent via <https://fsfe.org/internal/rc>.
|
||||
|
||||
Please find the expenses and their receipts attached.";
|
||||
|
||||
// Finalise output table
|
||||
$html .= "</table>";
|
||||
$html .= '</table>';
|
||||
if ($extra) {
|
||||
$html .= "<p>Extra remarks: <br />$extra</p>";
|
||||
$html .= "<p>Extra remarks: <br />{$extra}</p>";
|
||||
|
||||
$email_body .= "
|
||||
|
||||
The sender added the following comment:
|
||||
|
||||
$extra";
|
||||
{$extra}";
|
||||
}
|
||||
|
||||
// Send email, and delete attachments
|
||||
$email->Body = $email_body;
|
||||
if ($mailopt === "normal" || $mailopt === "onlyme") {
|
||||
if ('normal' === $mailopt || 'onlyme' === $mailopt) {
|
||||
$email->send();
|
||||
$html .= $email->ErrorInfo;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
|
||||
$config = [
|
||||
'fediverseuser' => '@fsfe@mastodon.social',
|
||||
'diasporauser' => '@{fsfe@diasp.eu}',
|
||||
'twitteruser' => 'fsfe',
|
||||
'flattruser' => 'fsfe',
|
||||
'supporturl' => 'https://my.fsfe.org/donate?referrer=share',
|
||||
'sharepic' => 'https://sharepic.fsfe.org'
|
||||
'fediverseuser' => '@fsfe@mastodon.social',
|
||||
'diasporauser' => '@{fsfe@diasp.eu}',
|
||||
'twitteruser' => 'fsfe',
|
||||
'flattruser' => 'fsfe',
|
||||
'supporturl' => 'https://my.fsfe.org/donate?referrer=share',
|
||||
'sharepic' => 'https://sharepic.fsfe.org',
|
||||
];
|
||||
|
||||
+85
-68
@@ -9,7 +9,7 @@
|
||||
* Upstream: https://git.fsfe.org/FSFE/share-buttons
|
||||
*/
|
||||
|
||||
/* load config. You normally don't want to edit something here */
|
||||
// load config. You normally don't want to edit something here
|
||||
require_once 'share-config.php';
|
||||
$fediverseuser = $config['fediverseuser'];
|
||||
$diasporauser = $config['diasporauser'];
|
||||
@@ -32,107 +32,124 @@ if (empty($service) || empty($url)) {
|
||||
$url = urlencode($url);
|
||||
$title = urlencode($title);
|
||||
|
||||
/* Special referrers for FSFE campaigns */
|
||||
if ($ref == "pmpc-side" || $ref == "pmpc-spread") {
|
||||
$via_fed = "";
|
||||
$via_tw = "";
|
||||
$via_dia = "";
|
||||
$sharepic = "https://sharepic.fsfe.org/pmpc";
|
||||
$supporturl = "https://my.fsfe.org/donate?referrer=pmpc";
|
||||
// Special referrers for FSFE campaigns
|
||||
if ('pmpc-side' == $ref || 'pmpc-spread' == $ref) {
|
||||
$via_fed = '';
|
||||
$via_tw = '';
|
||||
$via_dia = '';
|
||||
$sharepic = 'https://sharepic.fsfe.org/pmpc';
|
||||
$supporturl = 'https://my.fsfe.org/donate?referrer=pmpc';
|
||||
} else {
|
||||
$via_fed = " via " . $fediverseuser;
|
||||
$via_tw = "&via=" . $twitteruser;
|
||||
$via_dia = " via " . $diasporauser;
|
||||
$via_fed = ' via '.$fediverseuser;
|
||||
$via_tw = '&via='.$twitteruser;
|
||||
$via_dia = ' via '.$diasporauser;
|
||||
}
|
||||
|
||||
if ($service === "fediverse") {
|
||||
if ('fediverse' === $service) {
|
||||
$fediversepod = validateurl($fediversepod);
|
||||
$fediverse = which_fediverse($fediversepod);
|
||||
if ($fediverse === "mastodon") {
|
||||
if ('mastodon' === $fediverse) {
|
||||
// Mastodon
|
||||
header("Location: " . $fediversepod . "/share?text=" . $title . " " . $url . $via_fed);
|
||||
} elseif ($fediverse === "diaspora") {
|
||||
header('Location: '.$fediversepod.'/share?text='.$title.' '.$url.$via_fed);
|
||||
} elseif ('diaspora' === $fediverse) {
|
||||
// Diaspora
|
||||
header("Location: " . $fediversepod . "/bookmarklet?url=" . $url . "&title=" . $title . $via_dia);
|
||||
} elseif ($fediverse === "gnusocial") {
|
||||
header('Location: '.$fediversepod.'/bookmarklet?url='.$url.'&title='.$title.$via_dia);
|
||||
} elseif ('gnusocial' === $fediverse) {
|
||||
// GNU Social
|
||||
header("Location: " . $fediversepod . "/notice/new?status_textarea=" . $title . " " . $url . $via_fed);
|
||||
header('Location: '.$fediversepod.'/notice/new?status_textarea='.$title.' '.$url.$via_fed);
|
||||
} else {
|
||||
echo 'Your Fediverse instance is unknown. We cannot find out which service it belongs to, sorry.';
|
||||
}
|
||||
die();
|
||||
} elseif ($service === "reddit") {
|
||||
header("Location: https://reddit.com/submit?url=" . $url . "&title=" . $title);
|
||||
die();
|
||||
} elseif ($service === "flattr") {
|
||||
header("Location: https://flattr.com/submit/auto?user_id=" . $flattruser . "&url=" . $url . "&title=" . $title);
|
||||
die();
|
||||
} elseif ($service === "hnews") {
|
||||
header("Location: https://news.ycombinator.com/submitlink?u=" . $url . "&t=" . $title);
|
||||
die();
|
||||
} elseif ($service === "twitter") {
|
||||
header("Location: https://twitter.com/share?url=" . $url . "&text=" . $title . $via_tw);
|
||||
die();
|
||||
} elseif ($service === "facebook") {
|
||||
header("Location: https://www.facebook.com/sharer/sharer.php?u=" . $url);
|
||||
die();
|
||||
} elseif ($service === "gplus") {
|
||||
header("Location: https://plus.google.com/share?url=" . $url);
|
||||
die();
|
||||
} elseif ($service === "sharepic") {
|
||||
header("Location: " . $sharepic);
|
||||
die();
|
||||
} elseif ($service === "support") {
|
||||
header("Location: " . $supporturl);
|
||||
die();
|
||||
} else {
|
||||
echo 'Social network unknown.';
|
||||
|
||||
exit;
|
||||
}
|
||||
if ('reddit' === $service) {
|
||||
header('Location: https://reddit.com/submit?url='.$url.'&title='.$title);
|
||||
|
||||
exit;
|
||||
}
|
||||
if ('flattr' === $service) {
|
||||
header('Location: https://flattr.com/submit/auto?user_id='.$flattruser.'&url='.$url.'&title='.$title);
|
||||
|
||||
exit;
|
||||
}
|
||||
if ('hnews' === $service) {
|
||||
header('Location: https://news.ycombinator.com/submitlink?u='.$url.'&t='.$title);
|
||||
|
||||
exit;
|
||||
}
|
||||
if ('twitter' === $service) {
|
||||
header('Location: https://twitter.com/share?url='.$url.'&text='.$title.$via_tw);
|
||||
|
||||
exit;
|
||||
}
|
||||
if ('facebook' === $service) {
|
||||
header('Location: https://www.facebook.com/sharer/sharer.php?u='.$url);
|
||||
|
||||
exit;
|
||||
}
|
||||
if ('gplus' === $service) {
|
||||
header('Location: https://plus.google.com/share?url='.$url);
|
||||
|
||||
exit;
|
||||
}
|
||||
if ('sharepic' === $service) {
|
||||
header('Location: '.$sharepic);
|
||||
|
||||
exit;
|
||||
}
|
||||
if ('support' === $service) {
|
||||
header('Location: '.$supporturl);
|
||||
|
||||
exit;
|
||||
}
|
||||
echo 'Social network unknown.';
|
||||
}
|
||||
|
||||
// Sanitise URLs
|
||||
function validateurl($url)
|
||||
{
|
||||
// If Fediverse pod has been typed without http(s):// prefix, add it
|
||||
if (preg_match('#^https?://#i', $url) === 0) {
|
||||
$url = 'https://' . $url;
|
||||
if (0 === preg_match('#^https?://#i', $url)) {
|
||||
$url = 'https://'.$url;
|
||||
}
|
||||
// remove trailing spaces and slashes
|
||||
$url = trim($url, " /");
|
||||
|
||||
return $url;
|
||||
// remove trailing spaces and slashes
|
||||
return trim($url, ' /');
|
||||
}
|
||||
|
||||
// Is $pod a Mastodon instance or a GNU Social server?
|
||||
function getFediverseNetwork($pod)
|
||||
{
|
||||
$curl = curl_init($pod . "/api/statusnet/version.xml");
|
||||
$curl = curl_init($pod.'/api/statusnet/version.xml');
|
||||
curl_exec($curl);
|
||||
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
curl_close($curl);
|
||||
if ($code == 200) {
|
||||
if (200 == $code) {
|
||||
// GNU social server
|
||||
return 0;
|
||||
} else {
|
||||
// Mastodon server
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Mastodon server
|
||||
return 1;
|
||||
}
|
||||
|
||||
function which_fediverse($pod)
|
||||
{
|
||||
if (check_httpstatus($pod . "/api/v1/instance")) {
|
||||
if (check_httpstatus($pod.'/api/v1/instance')) {
|
||||
// Mastodon
|
||||
return "mastodon";
|
||||
} elseif (check_httpstatus($pod . "/api/statusnet/version.xml")) {
|
||||
// GNU social
|
||||
return "gnusocial";
|
||||
} elseif (check_httpstatus($pod . "/users/sign_in")) {
|
||||
// Diaspora
|
||||
return "diaspora";
|
||||
} else {
|
||||
return "none";
|
||||
return 'mastodon';
|
||||
}
|
||||
if (check_httpstatus($pod.'/api/statusnet/version.xml')) {
|
||||
// GNU social
|
||||
return 'gnusocial';
|
||||
}
|
||||
if (check_httpstatus($pod.'/users/sign_in')) {
|
||||
// Diaspora
|
||||
return 'diaspora';
|
||||
}
|
||||
|
||||
return 'none';
|
||||
}
|
||||
|
||||
function check_httpstatus($url)
|
||||
@@ -147,9 +164,9 @@ function check_httpstatus($url)
|
||||
$httpstatus = $headers[0];
|
||||
}
|
||||
// check if HTTP status is 200
|
||||
if (strpos($httpstatus, '200 OK') !== false) {
|
||||
if (false !== strpos($httpstatus, '200 OK')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>Dear <?=$name?>,</p>
|
||||
<p>Dear <?php echo $name; ?>,</p>
|
||||
<p>
|
||||
thank you for your recent request of promotional material from the FSFE!
|
||||
We've received your request and will normally be sending this to you
|
||||
@@ -12,8 +12,8 @@
|
||||
if (!empty($donationID)) {
|
||||
?>
|
||||
<p>If you have yet to make your donation, you may now do so by following
|
||||
this link: <a href=https://fsfe.org/order/payonline.<?=$lang?>/<?=$donationID?>>
|
||||
https://fsfe.org/order/payonline.<?=$lang?>/<?=$donationID?></a>. Once the donation is
|
||||
this link: <a href=https://fsfe.org/order/payonline.<?php echo $lang; ?>/<?php echo $donationID; ?>>
|
||||
https://fsfe.org/order/payonline.<?php echo $lang; ?>/<?php echo $donationID; ?></a>. Once the donation is
|
||||
confirmed the promotional material will be send.</p>
|
||||
<p>In case you prefer to pay by bank transfer, please use the following data:</p>
|
||||
<p>Recipient: Free Software Foundation Europe e.V.<br>
|
||||
@@ -21,8 +21,8 @@
|
||||
IBAN: DE47 4306 0967 2059 7908 01<br>
|
||||
Bank: GLS Gemeinschaftsbank eG, 44774 Bochum, Germany<br>
|
||||
BIC: GENODEM1GLS<br>
|
||||
Payment reference: <?=$donationID?><br>
|
||||
Payment amount: <?=$donate?> Euro</p>
|
||||
Payment reference: <?php echo $donationID; ?><br>
|
||||
Payment amount: <?php echo $donate; ?> Euro</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
} else {
|
||||
echo htmlspecialchars($startdate);
|
||||
} ?>">
|
||||
<?php if ($online === "yes") {
|
||||
$location = " ($location)";
|
||||
<?php if ('yes' === $online) {
|
||||
$location = " ({$location})";
|
||||
} else {
|
||||
$location = " in " . $location;
|
||||
$location = ' in '.$location;
|
||||
} ?>
|
||||
<title><?php echo htmlspecialchars($title) . $location; ?></title>
|
||||
<title><?php echo htmlspecialchars($title).$location; ?></title>
|
||||
<group>
|
||||
<name><?php echo htmlspecialchars($groupname); ?></name>
|
||||
<url><?php echo htmlspecialchars($groupurl); ?></url>
|
||||
@@ -22,12 +22,12 @@
|
||||
|
||||
<body>
|
||||
<p><?php echo str_replace(
|
||||
"</p><p>",
|
||||
'</p><p>',
|
||||
"</p>\n <p>",
|
||||
nl2br(
|
||||
preg_replace(
|
||||
"/(\r?\n){2,}/",
|
||||
"</p><p>",
|
||||
'</p><p>',
|
||||
htmlspecialchars($description)
|
||||
)
|
||||
)
|
||||
@@ -35,17 +35,17 @@
|
||||
</body>
|
||||
|
||||
<?php if ($url) {
|
||||
echo "<link>" . htmlspecialchars($url) . "</link>";
|
||||
echo '<link>'.htmlspecialchars($url).'</link>';
|
||||
} ?>
|
||||
|
||||
<tags>
|
||||
<?php if ($online !== "yes") { ?>
|
||||
<?php if ('yes' !== $online) { ?>
|
||||
<tag key="<?php echo strtolower(htmlspecialchars($countrycode)); ?>">
|
||||
<?php echo htmlspecialchars($countryname); ?>
|
||||
</tag>
|
||||
<?php } ?>
|
||||
<?php foreach ($tags as $tag) {
|
||||
echo sprintf('<tag key="%s"/>', htmlspecialchars($tag)) . "\n";
|
||||
echo sprintf('<tag key="%s"/>', htmlspecialchars($tag))."\n";
|
||||
} ?>
|
||||
<tag key="front-page"/>
|
||||
</tags>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<p>Hi <?=$name?>,<br />
|
||||
<p>Hi <?php echo $name; ?>,<br />
|
||||
You have registered an event on https://fsfe.org/events/tools/eventregistration</p>
|
||||
|
||||
<p>Below is the list of the information you gave.</p>
|
||||
<ul>
|
||||
<li>Name: <?=$name?></li>
|
||||
<li>Email: <?=$email?></li>
|
||||
<li>Event Title: <?=$title?></li>
|
||||
<li>Location: <?=$location?></li>
|
||||
<li>Name: <?php echo $name; ?></li>
|
||||
<li>Email: <?php echo $email; ?></li>
|
||||
<li>Event Title: <?php echo $title; ?></li>
|
||||
<li>Location: <?php echo $location; ?></li>
|
||||
</ul>
|
||||
|
||||
<p> You can review the information you have submitted at the automatically generated pull request <a href=<?=$pr_url?>>here</a>.
|
||||
<p> You can review the information you have submitted at the automatically generated pull request <a href=<?php echo $pr_url; ?>>here</a>.
|
||||
If you like to withdraw your event or in case you like to change some information,
|
||||
please contact contact@fsfe.org</p>
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ there is a new event registered on https://fsfe.org/events/tools/eventregistrati
|
||||
|
||||
<p>Below is a list of the information that were provided.</p>
|
||||
<ul>
|
||||
<li>Name: <?=$name?></li>
|
||||
<li>Email: <?=$email?></li>
|
||||
<li>Event Title: <?=$title?></li>
|
||||
<li>Location: <?=$location?></li>
|
||||
<li>Name: <?php echo $name; ?></li>
|
||||
<li>Email: <?php echo $email; ?></li>
|
||||
<li>Event Title: <?php echo $title; ?></li>
|
||||
<li>Location: <?php echo $location; ?></li>
|
||||
</ul>
|
||||
|
||||
<p>A pull request to the website has been automatically generated <a href=<?=$pr_url?>>here</a>. Please merge the Pull Request within 24 hours or contact the contributor for clarifications.</p>
|
||||
<p>A pull request to the website has been automatically generated <a href=<?php echo $pr_url; ?>>here</a>. Please merge the Pull Request within 24 hours or contact the contributor for clarifications.</p>
|
||||
|
||||
<p><?=$extra_message?></p>
|
||||
<p><?php echo $extra_message; ?></p>
|
||||
|
||||
<p>Thanks,<br />
|
||||
your website</p>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#format wiki
|
||||
#language en
|
||||
|
||||
= <?=$title?> =
|
||||
Start:: <?=$startdate?>
|
||||
End:: <?=$enddate?>
|
||||
Location:: <?=$location?>
|
||||
Link:: <?=$url?>
|
||||
= <?php echo $title; ?> =
|
||||
Start:: <?php echo $startdate; ?>
|
||||
End:: <?php echo $enddate; ?>
|
||||
Location:: <?php echo $location; ?>
|
||||
Link:: <?php echo $url; ?>
|
||||
bgcolor:: #FFFFFF
|
||||
Description:: <?=$description?>
|
||||
Description:: <?php echo $description; ?>
|
||||
|
||||
----
|
||||
[[Category/FellowshipEvents]]
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ pre-commit:
|
||||
glob: "*.php"
|
||||
exclude:
|
||||
- "fsfe.org/cgi-bin/PHPMailer/*.php"
|
||||
run: for file in {staged_files}; do php-cs-fixer --no-interaction fix "$file"; done
|
||||
run: php-cs-fixer --no-interaction --config=.php-cs-fixer.dist.php fix {staged_files}
|
||||
stage_fixed: true
|
||||
fail_on_changes: "ci"
|
||||
shfmt:
|
||||
|
||||
Reference in New Issue
Block a user