<?php
require_once($INC . "/prof.inc.php");
require_once($INC . "/log.inc.php");
require_once($INC . "/util.inc.php");
$rg_mail_error = "";
function rg_mail_set_error($str)
{
global $rg_mail_error;
$rg_mail_error = $str;
}
function rg_mail_error()
{
global $rg_mail_error;
return $rg_mail_error;
}
/*
* Function to send e-mails
* TODO: Replace mail() with rg_mail everywhere.
*/
function rg_mail_template($template, $more)
{
global $rg_admin_name, $rg_admin_email;
rg_prof_start("mail_template");
rg_log("mail_template: $template, more=" . rg_array2string($more));
$ret = FALSE;
while (1) {
if (!isset($more['ui']['ignore_confirmed']))
$more['ui']['ignore_confirmed'] = 0;
if (($more['ui']['ignore_confirmed'] == 0)
&& ($more['ui']['confirmed'] == 0)) {
rg_log('Confirmed is 0!');
$ret = TRUE;
break;
}
if (empty($more['ui']['email'])) {
rg_internal_error('email is not set in more array');
$ret = TRUE;
break;
}
if (!isset($more['debug']))
$more['debug'] = 0;
$more['HTML:rg_admin_email'] = $rg_admin_email;
$more['HTML:utf8_rg_admin_name'] = "=?UTF-8?B?"
. base64_encode($rg_admin_name) . "?=";
$subject = rg_template($template . ".subj.txt", $more, FALSE /*xss*/);
$subject = trim($subject);
$subject = str_replace("\r", '', $subject);
$subject = str_replace("\n", '', $subject);
// TODO: do not encode it as UTF-8 if not needed
$subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
$header = rg_template("mail/common.head.txt", $more, FALSE /*xss*/);
$header .= rg_template($template . ".head.txt", $more, FALSE /*xss*/);
$header = trim($header);
$body = rg_template($template . ".body.txt", $more, FALSE /*xss*/);
rg_log("CHECK: mail_template(" . $more['ui']['email'] . ",
$subject, $body, $header, -f $rg_admin_email");
if ($more['debug'] == 1) {
if (!isset($more['ui']['uid']))
$k = 0;
else
$k = $more['ui']['uid'];
rg_cache_set('DEBUG::' . $k . '::mail',
array(
'header' => $header,
'subject' => $subject,
'to' => $more['ui']['email'],
'body' => $body
), RG_SOCKET_NO_WAIT);
$ret = TRUE;
break;
}
$ret = mail($more['ui']['email'], $subject, $body, $header,
"-f $rg_admin_email");
if ($ret === FALSE)
rg_log("Sending mail failed to=" . $more['ui']['email']
. " subject=$subject!");
break;
}
rg_prof_end("mail_template");
return $ret;
}
?>
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master