Begin adding ability to modify layout, etc. based on User-Agent.
This commit is contained in:
parent
1aa93edf6f
commit
3550e09894
|
@ -1,6 +1,5 @@
|
|||
|
||||
<?php
|
||||
|
||||
include "config.inc.php";
|
||||
include "alphabet.inc.php";
|
||||
|
||||
|
@ -127,8 +126,7 @@ if(isset($_POST['command']) && $_POST['command'] == 'CreateNew') {
|
|||
}
|
||||
$verified = 1;
|
||||
}
|
||||
if ($userFileHandle = @fopen($userFilename, 'w+'))
|
||||
{
|
||||
if ($userFileHandle = @fopen($userFilename, 'w+')) {
|
||||
fwrite($userFileHandle, password_hash($password, PASSWORD_DEFAULT));
|
||||
fclose($userFileHandle);
|
||||
chmod($userFilename, 0666);
|
||||
|
@ -139,8 +137,7 @@ if(isset($_POST['command']) && $_POST['command'] == 'CreateNew') {
|
|||
$result = shell_exec("$synch_path/exec/makeuser $username -P $password");
|
||||
}
|
||||
$newkey = make_key($username);
|
||||
if ($userFileHandle = @fopen($keyFilename, 'w+'))
|
||||
{
|
||||
if ($userFileHandle = @fopen($keyFilename, 'w+')) {
|
||||
fwrite($userFileHandle, 'encryptionkey:' . $newkey . "\r\n");
|
||||
fwrite($userFileHandle, 'email:' . $user_email . "\r\n");
|
||||
if ($verified == 1) {
|
||||
|
@ -199,8 +196,7 @@ if (empty($_POST['username'])) {
|
|||
exit(2);
|
||||
}
|
||||
|
||||
if (strlen($clean_username) > 30)
|
||||
{
|
||||
if (strlen($clean_username) > 30) {
|
||||
echo "The maximum username length is 30 characters. You entered " . $clean_username . " which is " . strlen($cleanusername) . " characters long.<br />";
|
||||
echo '<form name="return1" method="post" action="register.php">';
|
||||
echo '<input name="username" type="hidden" id="username" value="' . $clean_username . '" readonly="readonly" maxlength="22">';
|
||||
|
@ -289,10 +285,8 @@ if (!preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z0-
|
|||
}
|
||||
|
||||
# Does user file already exist?
|
||||
if (($userFileHandle = @fopen($userFilename, 'r')) || (get_config_value('aliases.conf', strtolower($thisusername)) !== false))
|
||||
{
|
||||
if ($command == "Create")
|
||||
{
|
||||
if (($userFileHandle = @fopen($userFilename, 'r')) || (get_config_value('aliases.conf', strtolower($thisusername)) !== false)) {
|
||||
if ($command == "Create") {
|
||||
echo "User:" . $thisusername . " Already Exists\r\n";
|
||||
echo '<br /><a href="register.php">Back</a>';
|
||||
exit(2);
|
||||
|
@ -301,8 +295,7 @@ if (($userFileHandle = @fopen($userFilename, 'r')) || (get_config_value('aliases
|
|||
fclose($userFileHandle);
|
||||
|
||||
# User/Pass is correct
|
||||
if (password_verify ( $password , $userFileInfo))
|
||||
{
|
||||
if (password_verify($password, $userFileInfo)) {
|
||||
touch($userFilename);
|
||||
$ok = TRUE;
|
||||
} else {
|
||||
|
@ -313,31 +306,26 @@ if (($userFileHandle = @fopen($userFilename, 'r')) || (get_config_value('aliases
|
|||
}
|
||||
|
||||
# Ok to log in. User authenticated.
|
||||
if ($ok)
|
||||
{
|
||||
if ($ok) {
|
||||
echo "User:" . $thisusername . "\r\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
# Using external authentication
|
||||
if ($external)
|
||||
{
|
||||
if ($external) {
|
||||
$mbox = @imap_open($hostname, $username, $password);
|
||||
if ($mbox)
|
||||
{
|
||||
if ($mbox) {
|
||||
$ok = TRUE;
|
||||
imap_close($mbox);
|
||||
}
|
||||
}
|
||||
|
||||
# User is authenticated or to be created. Either way, create the file
|
||||
if ($ok || ($command == "Create") )
|
||||
{
|
||||
if ($ok || ($command == "Create")) {
|
||||
echo 'Create account: ' . $_POST['username'] . '<br/><br />';
|
||||
/* Generate email */
|
||||
# only check for no verification is the field has been populated
|
||||
if (!empty($CONFIG['no_verify']))
|
||||
{
|
||||
if (! empty($CONFIG['no_verify'])) {
|
||||
$no_verify = explode(' ', $CONFIG['no_verify']);
|
||||
foreach ($no_verify as $no) {
|
||||
if (strlen($_SERVER['HTTP_HOST']) - strlen($no) === strrpos($_SERVER['HTTP_HOST'], $no)) {
|
||||
|
@ -371,7 +359,8 @@ if ($ok || ($command == "Create") )
|
|||
|
||||
$mail->Port = $mailer['port'];
|
||||
$mail->Username = $mailer['username'];
|
||||
$mail->Password = $mailer['password'];;
|
||||
$mail->Password = $mailer['password'];
|
||||
;
|
||||
$mail->SMTPSecure = 'tls';
|
||||
|
||||
$mail->setFrom($mail_user . '@' . $mail_domain, $mail_name);
|
||||
|
@ -391,13 +380,10 @@ if ($ok || ($command == "Create") )
|
|||
$msg .= "Note: replies to this email address are checked daily.";
|
||||
$mail->Body = wordwrap($msg, 70);
|
||||
|
||||
if (!$mail->send())
|
||||
{
|
||||
if (! $mail->send()) {
|
||||
echo 'The message could not be sent.';
|
||||
echo '<p>Error: ' . $mail->ErrorInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
echo 'An email has been sent to ' . $user_email . '<br />';
|
||||
echo 'Please enter the code from the email below:<br />';
|
||||
}
|
||||
|
@ -414,22 +400,20 @@ if ($ok || ($command == "Create") )
|
|||
echo '<input name="key" type="hidden" value="' . password_hash($keys[0], PASSWORD_DEFAULT) . '">';
|
||||
echo '<input type="submit" name="Submit" value="Click Here to Create"></td>';
|
||||
echo '<br/><br/><a href="' . $CONFIG['default_content'] . '">Cancel and return to home page</a>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo "Authentication Failed\r\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function get_user_config($username,$request) {
|
||||
function get_user_config($username, $request)
|
||||
{
|
||||
global $config_dir;
|
||||
$userconfigpath = $config_dir . "userconfig/";
|
||||
$username = strtolower($username);
|
||||
$userFilename = $userconfigpath . $username;
|
||||
|
||||
if ($userFileHandle = @fopen($userFilename, 'r'))
|
||||
{
|
||||
while (!feof($userFileHandle))
|
||||
{
|
||||
if ($userFileHandle = @fopen($userFilename, 'r')) {
|
||||
while (! feof($userFileHandle)) {
|
||||
$buffer = fgets($userFileHandle);
|
||||
if (strpos($buffer, $request . ':') !== FALSE) {
|
||||
$userdataline = $buffer;
|
||||
|
@ -445,12 +429,14 @@ function get_user_config($username,$request) {
|
|||
}
|
||||
}
|
||||
|
||||
function make_key($username) {
|
||||
function make_key($username)
|
||||
{
|
||||
$key = openssl_random_pseudo_bytes(44);
|
||||
return base64_encode($key);
|
||||
}
|
||||
|
||||
function create_code($username) {
|
||||
function create_code($username)
|
||||
{
|
||||
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$code = substr(str_shuffle($permitted_chars), 0, 16);
|
||||
$userfile = sys_get_temp_dir() . "/" . $username;
|
||||
|
@ -458,13 +444,12 @@ function create_code($username) {
|
|||
return $code;
|
||||
}
|
||||
|
||||
function get_config_value($configfile,$request) {
|
||||
function get_config_value($configfile, $request)
|
||||
{
|
||||
global $config_dir;
|
||||
|
||||
if ($configFileHandle = @fopen($config_dir.'/'.$configfile, 'r'))
|
||||
{
|
||||
while (!feof($configFileHandle))
|
||||
{
|
||||
if ($configFileHandle = @fopen($config_dir . '/' . $configfile, 'r')) {
|
||||
while (! feof($configFileHandle)) {
|
||||
$buffer = fgets($configFileHandle);
|
||||
if (strpos($buffer, $request . ':') !== FALSE) {
|
||||
$dataline = $buffer;
|
||||
|
@ -480,7 +465,8 @@ function get_config_value($configfile,$request) {
|
|||
}
|
||||
}
|
||||
|
||||
function generateImage($text, $file) {
|
||||
function generateImage($text, $file)
|
||||
{
|
||||
$im = @imagecreate(74, 25) or die("Cannot Initialize new GD image stream");
|
||||
$background_color = imagecolorallocate($im, 200, 200, 200);
|
||||
$text_color = imagecolorallocate($im, 0, 0, 0);
|
||||
|
@ -489,13 +475,17 @@ function get_config_value($configfile,$request) {
|
|||
imagedestroy($im);
|
||||
}
|
||||
|
||||
function getIndex($alphabet, $letter) {
|
||||
function getIndex($alphabet, $letter)
|
||||
{
|
||||
for ($i = 0; $i < count($alphabet); $i ++) {
|
||||
$l = $alphabet[$i];
|
||||
if($l === $letter) return $i;
|
||||
if ($l === $letter)
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
function getExpressionResult($code) {
|
||||
|
||||
function getExpressionResult($code)
|
||||
{
|
||||
global $alphabet, $alphabetsForNumbers;
|
||||
$userAlphabetIndex = getIndex($alphabet, substr($code, 0, 1));
|
||||
$number1 = (int) getIndex($alphabetsForNumbers[$userAlphabetIndex], substr($code, 1, 1));
|
||||
|
@ -503,7 +493,8 @@ function get_config_value($configfile,$request) {
|
|||
return $number1 + $number2;
|
||||
}
|
||||
|
||||
function prepareCaptcha($captchaImage) {
|
||||
function prepareCaptcha($captchaImage)
|
||||
{
|
||||
global $alphabet, $alphabetsForNumbers;
|
||||
// generating expression
|
||||
$expression = (object) array(
|
||||
|
@ -513,9 +504,7 @@ function get_config_value($configfile,$request) {
|
|||
generateImage($expression->n1 . ' + ' . $expression->n2 . ' =', $captchaImage);
|
||||
|
||||
$usedAlphabet = rand(0, 9);
|
||||
$code = $alphabet[$usedAlphabet].
|
||||
$alphabetsForNumbers[$usedAlphabet][$expression->n1].
|
||||
$alphabetsForNumbers[$usedAlphabet][$expression->n2];
|
||||
$code = $alphabet[$usedAlphabet] . $alphabetsForNumbers[$usedAlphabet][$expression->n1] . $alphabetsForNumbers[$usedAlphabet][$expression->n2];
|
||||
return ($code);
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -61,8 +61,6 @@ if (strpos($id, '@') !== false) {
|
|||
if (isset($_REQUEST["first"]))
|
||||
$first = $_REQUEST["first"];
|
||||
|
||||
$_SESSION['rsactive'] = true;
|
||||
|
||||
if (! isset($_SERVER['REQUEST_STRING'])) {
|
||||
$_SERVER['REQUEST_STRING'] = '';
|
||||
}
|
||||
|
@ -103,6 +101,11 @@ if (! $message) {
|
|||
$title .= ' - ' . $group . ' - ' . $subject;
|
||||
}
|
||||
include "head.inc";
|
||||
|
||||
if ($client_device != "bot") {
|
||||
$_SESSION['rsactive'] = true;
|
||||
}
|
||||
|
||||
echo '<h1 class="np_thread_headline">';
|
||||
echo '<a href="' . $file_index . '" target=' . $frame['menu'] . '>' . basename(getcwd()) . '</a> / ';
|
||||
echo '<a href="' . $file_thread . '?group=' . rawurlencode($group) . '" target=' . $frame["content"] . '>' . htmlspecialchars(group_display_name($group)) . '</a> / ' . $subject . '</h1>';
|
||||
|
@ -117,6 +120,10 @@ if ($message) {
|
|||
// load thread-data and get IDs of the actual subthread
|
||||
$thread = thread_load($group);
|
||||
$subthread = thread_getsubthreadids($message->header->id, $thread);
|
||||
if (! $subthread) {
|
||||
echo '<center>Group is rebuilding... Please try again later</center>';
|
||||
exit();
|
||||
}
|
||||
if ($thread_articles == false) {
|
||||
sort($subthread);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,36 @@ echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
|
|||
echo '<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=<?=$www_charset?>">';
|
||||
include "config.inc.php";
|
||||
|
||||
// Try to get browser info to use for extra formatting of page
|
||||
$ua = strtolower($_SERVER["HTTP_USER_AGENT"]);
|
||||
$devices = array(
|
||||
"bot",
|
||||
"spider",
|
||||
"mobile",
|
||||
"lynx",
|
||||
"w3m",
|
||||
"links",
|
||||
"ipad",
|
||||
"tablet"
|
||||
);
|
||||
$client_device = "desktop";
|
||||
foreach ($devices as $device) {
|
||||
if (strpos($ua, $device) !== false) {
|
||||
$client_device = $device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($client_device == "spider") {
|
||||
$client_device = "bot";
|
||||
}
|
||||
// Log client device if enabled by semaphore
|
||||
if (file_exists($config_dir . '/devicelog.enable')) {
|
||||
$client_ip = getenv("REMOTE_ADDR");
|
||||
$logfile = $logdir . '/device.log';
|
||||
file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " Client: " . $client_ip . " browser: " . $client_device, FILE_APPEND);
|
||||
file_put_contents($logfile, "\nFull UA: ".$ua, FILE_APPEND);
|
||||
}
|
||||
|
||||
if (file_exists($config_dir . '/googleanalytics.conf')) {
|
||||
include $config_dir . '/googleanalytics.conf';
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
/* rslight NNTP<->HTTP Gateway
|
||||
|
||||
/*
|
||||
* rslight NNTP<->HTTP Gateway
|
||||
* Download: https://news.novabbs.com/getrslight
|
||||
*
|
||||
* Based on Newsportal by Florian Amrhein
|
||||
|
@ -21,13 +23,13 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
function message_parse($rawmessage) {
|
||||
function message_parse($rawmessage)
|
||||
{
|
||||
global $attachment_delete_alternative, $attachment_uudecode, $www_charset;
|
||||
global $iconv_enable;
|
||||
// Read the header of the message:
|
||||
$count_rawmessage = count($rawmessage);
|
||||
$message = new messageType;
|
||||
$message = new messageType();
|
||||
$rawheader = array();
|
||||
$i = 0;
|
||||
while ($rawmessage[$i] != "") {
|
||||
|
@ -48,19 +50,14 @@ function message_parse($rawmessage) {
|
|||
$i ++;
|
||||
$part = array();
|
||||
while ($i <= $count_rawmessage) {
|
||||
if (($rawmessage[$i]==$boundary) || ($i==$count_rawmessage-1) ||
|
||||
($rawmessage[$i]==$boundary.'--')) {
|
||||
if (($rawmessage[$i] == $boundary) || ($i == $count_rawmessage - 1) || ($rawmessage[$i] == $boundary . '--')) {
|
||||
$partmessage = message_parse($part);
|
||||
// merge the content-types of the message with those of the part
|
||||
for ($o = 0; $o < count($partmessage->header->content_type); $o ++) {
|
||||
$message->header->content_type[]=
|
||||
$partmessage->header->content_type[$o];
|
||||
$message->header->content_type_charset[]=
|
||||
$partmessage->header->content_type_charset[$o];
|
||||
$message->header->content_type_name[]=
|
||||
$partmessage->header->content_type_name[$o];
|
||||
$message->header->content_type_format[]=
|
||||
$partmessage->header->content_type_format[$o];
|
||||
$message->header->content_type[] = $partmessage->header->content_type[$o];
|
||||
$message->header->content_type_charset[] = $partmessage->header->content_type_charset[$o];
|
||||
$message->header->content_type_name[] = $partmessage->header->content_type_name[$o];
|
||||
$message->header->content_type_format[] = $partmessage->header->content_type_format[$o];
|
||||
$message->body[] = $partmessage->body[$o];
|
||||
}
|
||||
$part = array();
|
||||
|
@ -68,13 +65,13 @@ function message_parse($rawmessage) {
|
|||
if ($i < $count_rawmessage)
|
||||
$part[] = $rawmessage[$i];
|
||||
}
|
||||
if ($rawmessage[$i]==$boundary.'--') break;
|
||||
if ($rawmessage[$i] == $boundary . '--')
|
||||
break;
|
||||
$i ++;
|
||||
}
|
||||
// Is this a multipart/alternative multipart-message? Do we have to
|
||||
// delete all non plain/text parts?
|
||||
if (($attachment_delete_alternative) &&
|
||||
($content_type[1]=="alternative")) {
|
||||
if (($attachment_delete_alternative) && ($content_type[1] == "alternative")) {
|
||||
$plaintext = false;
|
||||
for ($o = 0; $o < count($message->header->content_type); $o ++) {
|
||||
if ($message->header->content_type[$o] == "text/plain")
|
||||
|
@ -99,8 +96,7 @@ function message_parse($rawmessage) {
|
|||
// Handle inline attachments
|
||||
for ($i ++; $i < $count_rawmessage; $i ++) {
|
||||
// do we have an inlay uuencoded file?
|
||||
if ((strtolower(substr($rawmessage[$i],0,10))!="begin 644 ") ||
|
||||
($attachment_uudecode==false)) {
|
||||
if ((strtolower(substr($rawmessage[$i], 0, 10)) != "begin 644 ") || ($attachment_uudecode == false)) {
|
||||
$body .= $rawmessage[$i] . "\n";
|
||||
// yes, it seems, we have!
|
||||
} else {
|
||||
|
@ -128,8 +124,7 @@ function message_parse($rawmessage) {
|
|||
$message->header->content_type_name[$uueatt] = "";
|
||||
for ($o = 2; $o < count($uue_infoline); $o ++)
|
||||
$message->header->content_type_name[$uueatt] .= $uue_infoline[$o];
|
||||
$message->header->content_type[$uueatt]=
|
||||
get_mimetype_by_string($message->body[$uueatt]);
|
||||
$message->header->content_type[$uueatt] = get_mimetype_by_string($message->body[$uueatt]);
|
||||
}
|
||||
} else {
|
||||
$body .= $rawmessage[$i] . "\n";
|
||||
|
@ -141,20 +136,25 @@ function message_parse($rawmessage) {
|
|||
|
||||
$body = decode_body($body, $message->header->content_transfer_encoding);
|
||||
if (isset($message->header->content_type_charset)) {
|
||||
$body=recode_charset($body,
|
||||
$message->header->content_type_charset[0],
|
||||
$www_charset);
|
||||
$body = recode_charset($body, $message->header->content_type_charset[0], $www_charset);
|
||||
}
|
||||
if ($body=="") $body=" ";
|
||||
if ($body == "")
|
||||
$body = " ";
|
||||
// }
|
||||
$message->body[0] = $body;
|
||||
}
|
||||
if (! isset($message->header->content_type_charset))
|
||||
$message->header->content_type_charset=array($www_charset);
|
||||
$message->header->content_type_charset = array(
|
||||
$www_charset
|
||||
);
|
||||
if (! isset($message->header->content_type_name))
|
||||
$message->header->content_type_name=array("unnamed");
|
||||
$message->header->content_type_name = array(
|
||||
"unnamed"
|
||||
);
|
||||
if (! isset($message->header->content_type_format))
|
||||
$message->header->content_type_format=array("fixed");
|
||||
$message->header->content_type_format = array(
|
||||
"fixed"
|
||||
);
|
||||
for ($o = 0; $o < count($message->body); $o ++) {
|
||||
if (! isset($message->header->content_type_charset[$o]))
|
||||
$message->header->content_type_charset[$o] = $www_charset;
|
||||
|
@ -166,7 +166,6 @@ function message_parse($rawmessage) {
|
|||
return $message;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* read an article from the newsserver or the spool-directory
|
||||
*
|
||||
|
@ -180,7 +179,8 @@ function message_parse($rawmessage) {
|
|||
* doesn't exists on the newsserver or doesn't contain the given
|
||||
* attachment.
|
||||
*/
|
||||
function message_read($id,$bodynum=0,$group="") {
|
||||
function message_read($id, $bodynum = 0, $group = "")
|
||||
{
|
||||
global $CONFIG, $config_name, $cache_articles, $spooldir, $spoolpath, $logdir, $text_error, $ns;
|
||||
$logfile = $logdir . '/newsportal.log';
|
||||
if (! testGroup($group)) {
|
||||
|
@ -190,7 +190,7 @@ function message_read($id,$bodynum=0,$group="") {
|
|||
if (! is_numeric($id)) {
|
||||
return false;
|
||||
}
|
||||
$message = new messageType;
|
||||
$message = new messageType();
|
||||
if ((isset($cache_articles)) && ($cache_articles == true)) {
|
||||
// Try to load a cached article
|
||||
if ((preg_match('/^[0-9]+$/', $id)) && ($group != ''))
|
||||
|
@ -207,21 +207,15 @@ function message_read($id,$bodynum=0,$group="") {
|
|||
unset($message->header);
|
||||
}
|
||||
// Is a non-existing attachment of an article requested?
|
||||
if ((isset($message->header)) &&
|
||||
($bodynum!= -1) &&
|
||||
(!isset($message->header->content_type[$bodynum])))
|
||||
if ((isset($message->header)) && ($bodynum != - 1) && (! isset($message->header->content_type[$bodynum])))
|
||||
return false;
|
||||
if ((file_exists($cachefilename_body.$bodynum)) &&
|
||||
($bodynum != -1)) {
|
||||
if ((file_exists($cachefilename_body . $bodynum)) && ($bodynum != - 1)) {
|
||||
$cachefile = fopen($cachefilename_body . $bodynum, "r");
|
||||
$message->body[$bodynum]=
|
||||
fread($cachefile,filesize($cachefilename_body.$bodynum));
|
||||
$message->body[$bodynum] = fread($cachefile, filesize($cachefilename_body . $bodynum));
|
||||
fclose($cachefile);
|
||||
}
|
||||
}
|
||||
if ((!isset($message->header)) ||
|
||||
((!isset($message->body[$bodynum])) &&
|
||||
($bodynum != -1))) {
|
||||
if ((! isset($message->header)) || ((! isset($message->body[$bodynum])) && ($bodynum != - 1))) {
|
||||
// Pull article from spool if exists, else from server
|
||||
if (trim($group) == '') {
|
||||
return false;
|
||||
|
@ -271,7 +265,8 @@ function message_read($id,$bodynum=0,$group="") {
|
|||
}
|
||||
}
|
||||
$message = message_parse($rawmessage);
|
||||
if (preg_match('/^[0-9]+$/',$id)) $message->header->number=$id;
|
||||
if (preg_match('/^[0-9]+$/', $id))
|
||||
$message->header->number = $id;
|
||||
// write header, body and attachments to the cache
|
||||
if ((isset($cache_articles)) && ($cache_articles == true)) {
|
||||
$cachefile = fopen($cachefilename_header, "w");
|
||||
|
@ -291,7 +286,8 @@ function message_read($id,$bodynum=0,$group="") {
|
|||
return $message;
|
||||
}
|
||||
|
||||
function textwrap($text, $wrap=80, $break="\n",$maxlen=false){
|
||||
function textwrap($text, $wrap = 80, $break = "\n", $maxlen = false)
|
||||
{
|
||||
$len = strlen($text);
|
||||
if ($len > $wrap) {
|
||||
$h = ''; // massaged text
|
||||
|
@ -319,17 +315,21 @@ function textwrap($text, $wrap=80, $break="\n",$maxlen=false){
|
|||
}
|
||||
return $h;
|
||||
}
|
||||
|
||||
/*
|
||||
* Displays a (Sub)-Thread. Is used in article.php
|
||||
*
|
||||
* $id: Message-ID (not number!) of an article in the thread
|
||||
* $group: name of the newsgroup
|
||||
*/
|
||||
function message_thread($id,$group,$thread,$highlightids=false) {
|
||||
function message_thread($id, $group, $thread, $highlightids = false)
|
||||
{
|
||||
$current = $id;
|
||||
// set the highlightid, if not set
|
||||
if (! $highlightids)
|
||||
$highlightids=array($current);
|
||||
$highlightids = array(
|
||||
$current
|
||||
);
|
||||
flush();
|
||||
// find the first article in the subthread of $id
|
||||
while (isset($thread[$id]->references)) {
|
||||
|
@ -356,7 +356,8 @@ function message_thread($id,$group,$thread,$highlightids=false) {
|
|||
* $group: the name of the newsgroup, is needed for the links to post.php3
|
||||
* and the header.
|
||||
*/
|
||||
function show_header($head,$group,$local_poster=false) {
|
||||
function show_header($head, $group, $local_poster = false)
|
||||
{
|
||||
global $article_show, $text_header, $file_article, $attachment_show;
|
||||
global $file_attachment, $anonym_address, $CONFIG;
|
||||
if (isset($_COOKIE['tzo'])) {
|
||||
|
@ -365,7 +366,8 @@ function show_header($head,$group,$local_poster=false) {
|
|||
$offset = intval($CONFIG['timezone']);
|
||||
}
|
||||
echo '<div class="np_article_header">';
|
||||
if ($article_show["Subject"]) echo $text_header["subject"].htmlspecialchars($head->subject)."<br>";
|
||||
if ($article_show["Subject"])
|
||||
echo $text_header["subject"] . htmlspecialchars($head->subject) . "<br>";
|
||||
if ($article_show["From"]) {
|
||||
echo $text_header["from"];
|
||||
if ($head->from == $anonym_address) {
|
||||
|
@ -375,9 +377,7 @@ function show_header($head,$group,$local_poster=false) {
|
|||
if ($article_show["From_link"])
|
||||
echo '<a href="mailto:' . htmlspecialchars($head->from) . '">';
|
||||
if (isset($article_show["From_rewrite"]))
|
||||
echo preg_replace('/{$article_show["From_rewrite"][0]}/',
|
||||
$article_show["From_rewrite"][1],
|
||||
htmlspecialchars($head->from));
|
||||
echo preg_replace('/{$article_show["From_rewrite"][0]}/', $article_show["From_rewrite"][1], htmlspecialchars($head->from));
|
||||
$before_at = explode('@', $head->from);
|
||||
$namelen = strlen($before_at[0]);
|
||||
if ($namelen > 3) {
|
||||
|
@ -417,10 +417,8 @@ function show_header($head,$group,$local_poster=false) {
|
|||
echo $text_header["newsgroups"] . htmlspecialchars(str_replace(',', ', ', $head->newsgroups)) . "<br>\n";
|
||||
if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != ""))
|
||||
echo $text_header["followup"] . htmlspecialchars($head->followup) . "<br>\n";
|
||||
if ((isset($head->organization)) && ($article_show["Organization"]) &&
|
||||
($head->organization != ""))
|
||||
echo $text_header["organization"].
|
||||
html_parse(htmlspecialchars($head->organization))."<br>\n";
|
||||
if ((isset($head->organization)) && ($article_show["Organization"]) && ($head->organization != ""))
|
||||
echo $text_header["organization"] . html_parse(htmlspecialchars($head->organization)) . "<br>\n";
|
||||
if ($article_show["Date"]) {
|
||||
$ts = new DateTime(date($text_header["date_format"], $head->date), new DateTimeZone('UTC'));
|
||||
$ts->add(DateInterval::createFromDateString($offset . ' minutes'));
|
||||
|
@ -440,21 +438,18 @@ function show_header($head,$group,$local_poster=false) {
|
|||
echo $text_header["references"];
|
||||
for ($i = 0; $i <= count($head->references) - 1; $i ++) {
|
||||
$ref = $head->references[$i];
|
||||
echo ' '.'<a href="'.$file_article.'?group='.urlencode($group).
|
||||
'&id='.urlencode($ref).'">'.($i+1).'</a>';
|
||||
echo ' ' . '<a href="' . $file_article . '?group=' . urlencode($group) . '&id=' . urlencode($ref) . '">' . ($i + 1) . '</a>';
|
||||
}
|
||||
echo "<br>";
|
||||
}
|
||||
if (isset($head->user_agent)) {
|
||||
if ((isset($article_show["User-Agent"])) &&
|
||||
($article_show["User-Agent"])) {
|
||||
if ((isset($article_show["User-Agent"])) && ($article_show["User-Agent"])) {
|
||||
echo $text_header["user-agent"] . htmlspecialchars($head->user_agent) . "<br>\n";
|
||||
} else {
|
||||
echo "<!-- User-Agent: " . htmlspecialchars($head->user_agent) . " -->\n";
|
||||
}
|
||||
}
|
||||
if ((isset($attachment_show)) && ($attachment_show==true) &&
|
||||
(isset($head->content_type[1]))) {
|
||||
if ((isset($attachment_show)) && ($attachment_show == true) && (isset($head->content_type[1]))) {
|
||||
echo $text_header["attachments"];
|
||||
for ($i = 1; $i < count($head->content_type); $i ++) {
|
||||
if (! strcmp($head->content_type[$i], "text/html")) {
|
||||
|
@ -462,12 +457,9 @@ function show_header($head,$group,$local_poster=false) {
|
|||
} else {
|
||||
$contype = $head->content_type_name[$i];
|
||||
}
|
||||
echo '<a href="'.$file_attachment.'?group='.urlencode($group).'&'.
|
||||
'id='.urlencode($head->number).'&'.
|
||||
'attachment='.$i.'">'.
|
||||
$contype.'</a> ('.
|
||||
$head->content_type[$i].')';
|
||||
if ($i<count($head->content_type)-1) echo ', ';
|
||||
echo '<a href="' . $file_attachment . '?group=' . urlencode($group) . '&' . 'id=' . urlencode($head->number) . '&' . 'attachment=' . $i . '">' . $contype . '</a> (' . $head->content_type[$i] . ')';
|
||||
if ($i < count($head->content_type) - 1)
|
||||
echo ', ';
|
||||
}
|
||||
}
|
||||
if ($article_show["trigger_headers"]) {
|
||||
|
@ -480,7 +472,8 @@ function show_header($head,$group,$local_poster=false) {
|
|||
echo '</div>';
|
||||
}
|
||||
|
||||
function display_full_headers($article,$group,$name,$from,$getface=false) {
|
||||
function display_full_headers($article, $group, $name, $from, $getface = false)
|
||||
{
|
||||
global $spoolpath, $CONFIG;
|
||||
if ($CONFIG['article_database'] == '1') {
|
||||
$message = np_get_db_article($article, $group, 1);
|
||||
|
@ -540,13 +533,15 @@ function display_full_headers($article,$group,$name,$from,$getface=false) {
|
|||
}
|
||||
return ($return);
|
||||
}
|
||||
|
||||
/*
|
||||
* decodes a body. Splits the content of $body into an array of several
|
||||
* lines, respecting the special decoding issues of format=flowed
|
||||
* articles. Each returned line consists of two fields: text and
|
||||
* the quote depth (depth)
|
||||
*/
|
||||
function decode_textbody($body,$format="fixed") {
|
||||
function decode_textbody($body, $format = "fixed")
|
||||
{
|
||||
$tmp = new \stdClass();
|
||||
$body = explode("\n", $body);
|
||||
$nbody = array();
|
||||
|
@ -568,8 +563,7 @@ function decode_textbody($body,$format="fixed") {
|
|||
}
|
||||
}
|
||||
// generate a new paragraph?
|
||||
if(($i>0) && (($ndepth!=$depth) || $format!="flowed" ||
|
||||
(@$paragraph[strlen($paragraph)-1]!=' ')) || ($i==count($body))) {
|
||||
if (($i > 0) && (($ndepth != $depth) || $format != "flowed" || (@$paragraph[strlen($paragraph) - 1] != ' ')) || ($i == count($body))) {
|
||||
$tmp->text = $paragraph;
|
||||
$tmp->depth = $depth;
|
||||
$paragraph = "";
|
||||
|
@ -578,7 +572,8 @@ function decode_textbody($body,$format="fixed") {
|
|||
else
|
||||
$nbody[] = $tmp;
|
||||
}
|
||||
if(@$body[$i]=="-- " && $format=="flowed") $body[$i]="--";
|
||||
if (@$body[$i] == "-- " && $format == "flowed")
|
||||
$body[$i] = "--";
|
||||
$paragraph .= substr(@$body[$i], $tdepth);
|
||||
$depth = $ndepth;
|
||||
}
|
||||
|
@ -589,24 +584,41 @@ function decode_textbody($body,$format="fixed") {
|
|||
* replaces multiple spaces in texts by es and convert special-chars
|
||||
* to their entities
|
||||
*/
|
||||
function text2html($text) {
|
||||
function text2html($text)
|
||||
{
|
||||
// These features have been replaced by css
|
||||
return $text;
|
||||
}
|
||||
|
||||
function nl2p($string, $line_breaks = true, $xml = true) {
|
||||
|
||||
$string = str_replace(array('<p>', '</p>', '<br>', '<br />'), '', $string);
|
||||
function nl2p($string, $line_breaks = true, $xml = true)
|
||||
{
|
||||
$string = str_replace(array(
|
||||
'<p>',
|
||||
'</p>',
|
||||
'<br>',
|
||||
'<br />'
|
||||
), '', $string);
|
||||
|
||||
// It is conceivable that people might still want single line-breaks
|
||||
// without breaking into a new paragraph.
|
||||
if ($line_breaks == true)
|
||||
return '<p>'.preg_replace(array("/([\n]{2,})/i", "/([^>])\n([^<])/i"), array("</p>\n<p>", '$1<br'.($xml == true ? ' /' : '').'>$2'), trim($string)).'</p>';
|
||||
return '<p>' . preg_replace(array(
|
||||
"/([\n]{2,})/i",
|
||||
"/([^>])\n([^<])/i"
|
||||
), array(
|
||||
"</p>\n<p>",
|
||||
'$1<br' . ($xml == true ? ' /' : '') . '>$2'
|
||||
), trim($string)) . '</p>';
|
||||
else
|
||||
return '<p>'.preg_replace(
|
||||
array("/([\n]{2,})/i", "/([\r\n]{3,})/i","/([^>])\n([^<])/i"),
|
||||
array("</p>\n<p>", "</p>\n<p>", '$1<br'.($xml == true ? ' /' : '').'>$2'),
|
||||
|
||||
return '<p>' . preg_replace(array(
|
||||
"/([\n]{2,})/i",
|
||||
"/([\r\n]{3,})/i",
|
||||
"/([^>])\n([^<])/i"
|
||||
), array(
|
||||
"</p>\n<p>",
|
||||
"</p>\n<p>",
|
||||
'$1<br' . ($xml == true ? ' /' : '') . '>$2'
|
||||
),
|
||||
trim($string)) . '</p>';
|
||||
}
|
||||
|
||||
|
@ -618,7 +630,8 @@ function nl2p($string, $line_breaks = true, $xml = true) {
|
|||
* $attachment: The number of the attachment of the article.
|
||||
* 0 means the normal textbody.
|
||||
*/
|
||||
function message_show($group,$id,$attachment=0,$article_data=false,$maxlen=false) {
|
||||
function message_show($group, $id, $attachment = 0, $article_data = false, $maxlen = false)
|
||||
{
|
||||
global $file_article, $file_article_full;
|
||||
global $text_header, $text_article, $article_showthread, $file_attachment, $attachment_show;
|
||||
global $block_xnoarchive, $article_graphicquotes;
|
||||
|
@ -635,12 +648,9 @@ function message_show($group,$id,$attachment=0,$article_data=false,$maxlen=false
|
|||
}
|
||||
$body = $article_data->body[$attachment];
|
||||
if ($head) {
|
||||
if (($block_xnoarchive) && (isset($head->xnoarchive)) &&
|
||||
($head->xnoarchive=="yes")) {
|
||||
if (($block_xnoarchive) && (isset($head->xnoarchive)) && ($head->xnoarchive == "yes")) {
|
||||
echo $text_article["block-xnoarchive"];
|
||||
} else
|
||||
if (($head->content_type[$attachment]=="text/plain") &&
|
||||
($attachment==0)) {
|
||||
} else if (($head->content_type[$attachment] == "text/plain") && ($attachment == 0)) {
|
||||
show_header($head, $group, $local_poster);
|
||||
// X-Face
|
||||
if ($face = display_full_headers($head->number, $group, $head->name, $head->from, true)) {
|
||||
|
@ -676,14 +686,14 @@ function message_show($group,$id,$attachment=0,$article_data=false,$maxlen=false
|
|||
}
|
||||
if ($encrypted === false) {
|
||||
$body = nl2p(htmlspecialchars($body));
|
||||
$body=decode_textbody($body,
|
||||
$article_data->header->content_type_format[$attachment]);
|
||||
}
|
||||
/* FIXME
|
||||
if((isset($article_data->header->rslight_to)) && !(password_verify($CONFIG['thissitekey'].$head->id, $head->rslight_site))) {
|
||||
echo "<b>rslight encrypted message.</b>";
|
||||
$body="";
|
||||
$body = decode_textbody($body, $article_data->header->content_type_format[$attachment]);
|
||||
}
|
||||
/*
|
||||
* FIXME
|
||||
* if((isset($article_data->header->rslight_to)) && !(password_verify($CONFIG['thissitekey'].$head->id, $head->rslight_site))) {
|
||||
* echo "<b>rslight encrypted message.</b>";
|
||||
* $body="";
|
||||
* }
|
||||
*/
|
||||
$depth = 0;
|
||||
if (isset($CONFIG['synchronet']) && ($CONFIG['synchronet'] == true)) {
|
||||
|
@ -692,8 +702,7 @@ function message_show($group,$id,$attachment=0,$article_data=false,$maxlen=false
|
|||
echo '<div class="np_article_body">';
|
||||
}
|
||||
$currentlen = 0; // needed if $maxlen is set
|
||||
for ($i=0; $i<=count($body) &&
|
||||
(($currentlen<$maxlen) || ($maxlen==false)); $i++) {
|
||||
for ($i = 0; $i <= count($body) && (($currentlen < $maxlen) || ($maxlen == false)); $i ++) {
|
||||
// HTMLized Quotings instead of boring > ?
|
||||
if ($article_graphicquotes) {
|
||||
// HTMLized Quotings
|
||||
|
@ -714,23 +723,17 @@ function message_show($group,$id,$attachment=0,$article_data=false,$maxlen=false
|
|||
else
|
||||
$t = @$body[$i]->text;
|
||||
} else {
|
||||
$t='<i>'.str_repeat('>',$body[$i]->depth).' '.
|
||||
html_parse(text2html(
|
||||
textwrap($body[$i]->text,72-$body[$i]->depth,
|
||||
"\n".str_repeat('>',$body[$i]->depth).' '))).
|
||||
"</i><br>\n";
|
||||
$t = '<i>' . str_repeat('>', $body[$i]->depth) . ' ' . html_parse(text2html(textwrap($body[$i]->text, 72 - $body[$i]->depth, "\n" . str_repeat('>', $body[$i]->depth) . ' '))) . "</i><br>\n";
|
||||
}
|
||||
echo $t;
|
||||
$currentlen += strlen($t);
|
||||
}
|
||||
}
|
||||
if ($maxlen != false && $currentlen >= $maxlen) {
|
||||
echo '<br><a href="'.$file_article_full.'?id='.$id.'&group='.
|
||||
$group.'">'.$text_article["full_article"].'</a>';
|
||||
echo '<br><a href="' . $file_article_full . '?id=' . $id . '&group=' . $group . '">' . $text_article["full_article"] . '</a>';
|
||||
}
|
||||
// If attachment is image embed into article
|
||||
if ((isset($attachment_show)) && ($attachment_show==true) &&
|
||||
(isset($head->content_type[1]))) {
|
||||
if ((isset($attachment_show)) && ($attachment_show == true) && (isset($head->content_type[1]))) {
|
||||
echo $text_header["attachments"];
|
||||
for ($i = 1; $i < count($head->content_type); $i ++) {
|
||||
if (! strcmp($head->content_type[$i], "text/html")) {
|
||||
|
@ -740,20 +743,12 @@ if ((isset($attachment_show)) && ($attachment_show==true) &&
|
|||
}
|
||||
$type = explode('/', $head->content_type[$i]);
|
||||
if (trim($type[0]) == "image") {
|
||||
echo '<a href="'.$file_attachment.'?group='.urlencode($group).'&'.
|
||||
'id='.urlencode($head->number).'&'.
|
||||
'attachment='.$i.'">'.
|
||||
'<img src="'.$file_attachment.'?group='.urlencode($group).'&'.
|
||||
'id='.urlencode($head->number).'&'.
|
||||
'attachment='.$i.'" title="'.$contype.'" alt="'.$contype.'" style="max-width: 20vw; max-height: 100px;"></a> ';
|
||||
echo '<a href="' . $file_attachment . '?group=' . urlencode($group) . '&' . 'id=' . urlencode($head->number) . '&' . 'attachment=' . $i . '">' . '<img src="' . $file_attachment . '?group=' . urlencode($group) . '&' . 'id=' . urlencode($head->number) . '&' . 'attachment=' . $i . '" title="' . $contype . '" alt="' . $contype . '" style="max-width: 20vw; max-height: 100px;"></a> ';
|
||||
} else {
|
||||
echo '<a href="'.$file_attachment.'?group='.urlencode($group).'&'.
|
||||
'id='.urlencode($head->number).'&'.
|
||||
'attachment='.$i.'">'.
|
||||
$contype.'</a> ('.
|
||||
$head->content_type[$i].')';
|
||||
echo '<a href="' . $file_attachment . '?group=' . urlencode($group) . '&' . 'id=' . urlencode($head->number) . '&' . 'attachment=' . $i . '">' . $contype . '</a> (' . $head->content_type[$i] . ')';
|
||||
}
|
||||
if ($i<count($head->content_type)-1) echo ', ';
|
||||
if ($i < count($head->content_type) - 1)
|
||||
echo ', ';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
@ -764,7 +759,8 @@ if ((isset($attachment_show)) && ($attachment_show==true) &&
|
|||
echo '</div>';
|
||||
}
|
||||
|
||||
function message_decrypt($key,$group,$id,$attachment=0,$article_data=false,$maxlen=false) {
|
||||
function message_decrypt($key, $group, $id, $attachment = 0, $article_data = false, $maxlen = false)
|
||||
{
|
||||
global $file_article, $file_article_full;
|
||||
global $text_header, $text_article, $article_showthread;
|
||||
global $block_xnoarchive, $article_graphicquotes;
|
||||
|
@ -773,25 +769,20 @@ function message_decrypt($key,$group,$id,$attachment=0,$article_data=false,$maxl
|
|||
$head = $article_data->header;
|
||||
$body = $article_data->body[$attachment];
|
||||
if ($head) {
|
||||
if (($block_xnoarchive) && (isset($head->xnoarchive)) &&
|
||||
($head->xnoarchive=="yes")) {
|
||||
if (($block_xnoarchive) && (isset($head->xnoarchive)) && ($head->xnoarchive == "yes")) {
|
||||
echo $text_article["block-xnoarchive"];
|
||||
} else
|
||||
if (($head->content_type[$attachment]=="text/plain") &&
|
||||
($attachment==0)) {
|
||||
} else if (($head->content_type[$attachment] == "text/plain") && ($attachment == 0)) {
|
||||
show_header($head, $group);
|
||||
// RSLIGHT Decrypt here
|
||||
$body = str_replace("-- RSLIGHT DAT START\n", "", $body);
|
||||
$body = str_replace("\n-- RSLIGHT DAT END", "", $body);
|
||||
$body = rslight_decrypt($body, $key);
|
||||
$body=decode_textbody($body,
|
||||
$article_data->header->content_type_format[$attachment]);
|
||||
$body = decode_textbody($body, $article_data->header->content_type_format[$attachment]);
|
||||
$depth = 0;
|
||||
echo '<div class="np_article_body">';
|
||||
echo "(Copy text below to quote in reply)<br /><br />";
|
||||
$currentlen = 0; // needed if $maxlen is set
|
||||
for ($i=0; $i<=count($body) &&
|
||||
(($currentlen<$maxlen) || ($maxlen==false)); $i++) {
|
||||
for ($i = 0; $i <= count($body) && (($currentlen < $maxlen) || ($maxlen == false)); $i ++) {
|
||||
// HTMLized Quotings instead of boring > ?
|
||||
if ($article_graphicquotes) {
|
||||
// HTMLized Quotings
|
||||
|
@ -812,11 +803,7 @@ function message_decrypt($key,$group,$id,$attachment=0,$article_data=false,$maxl
|
|||
else
|
||||
$t = html_parse(text2html($body[$i]->text)) . "<br>\n";
|
||||
} else {
|
||||
$t='<i>'.str_repeat('>',$body[$i]->depth).' '.
|
||||
html_parse(text2html(
|
||||
textwrap($body[$i]->text,72-$body[$i]->depth,
|
||||
"\n".str_repeat('>',$body[$i]->depth).' '))).
|
||||
"</i><br>\n";
|
||||
$t = '<i>' . str_repeat('>', $body[$i]->depth) . ' ' . html_parse(text2html(textwrap($body[$i]->text, 72 - $body[$i]->depth, "\n" . str_repeat('>', $body[$i]->depth) . ' '))) . "</i><br>\n";
|
||||
}
|
||||
echo $t;
|
||||
$currentlen += strlen($t);
|
||||
|
@ -824,19 +811,20 @@ function message_decrypt($key,$group,$id,$attachment=0,$article_data=false,$maxl
|
|||
}
|
||||
echo '</div>';
|
||||
if ($maxlen != false && $currentlen >= $maxlen) {
|
||||
echo '<br><a href="'.$file_article_full.'?id='.$id.'&group='.
|
||||
$group.'">'.$text_article["full_article"].'</a>';
|
||||
echo '<br><a href="' . $file_article_full . '?id=' . $id . '&group=' . $group . '">' . $text_article["full_article"] . '</a>';
|
||||
}
|
||||
} else {
|
||||
echo $body;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Shows the little menu on article-flat.php where you can select the
|
||||
* different pages with the articles on it
|
||||
*/
|
||||
function articleflat_pageselect($group,$id,$article_count,$first) {
|
||||
function articleflat_pageselect($group, $id, $article_count, $first)
|
||||
{
|
||||
global $articleflat_articles_per_page, $file_article, $file_framethread, $name;
|
||||
global $text_thread, $thread_show;
|
||||
$pages = ceil($article_count / $articleflat_articles_per_page);
|
||||
|
@ -845,11 +833,7 @@ function articleflat_pageselect($group,$id,$article_count,$first) {
|
|||
$return .= $text_thread["pages"];
|
||||
for ($i = 0; $i < $pages; $i ++) {
|
||||
if ($first != $i * $articleflat_articles_per_page + 1)
|
||||
$return.= '<a class="np_pages_unselected" href="'.
|
||||
$file_article.'?group='._rawurlencode($group).
|
||||
'&id='.urlencode($id).
|
||||
'&first='.($i*$articleflat_articles_per_page+1).'&last='.
|
||||
($i+1)*$articleflat_articles_per_page.'#start">';
|
||||
$return .= '<a class="np_pages_unselected" href="' . $file_article . '?group=' . _rawurlencode($group) . '&id=' . urlencode($id) . '&first=' . ($i * $articleflat_articles_per_page + 1) . '&last=' . ($i + 1) * $articleflat_articles_per_page . '#start">';
|
||||
else
|
||||
$return .= '<span class="np_pages_selected">';
|
||||
$return .= $i + 1;
|
||||
|
|
|
@ -1715,6 +1715,23 @@ function get_config_value($configfile, $request)
|
|||
}
|
||||
}
|
||||
|
||||
function disable_page_by_user_agent($client_device, $useragent, $script = "Page")
|
||||
{
|
||||
global $logdir, $config_name, $count_bots;
|
||||
if ($client_device == $useragent) {
|
||||
$logfile = $logdir . '/device.log';
|
||||
file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " " . $script . " disabled for '" . $useragent . "' Exiting...", FILE_APPEND);
|
||||
if ($client_device == "bot") {
|
||||
if (isset($_SESSION['rsactive'])) {
|
||||
unset($_SESSION['rsactive']);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function throttle_hits()
|
||||
{
|
||||
global $CONFIG, $logdir;
|
||||
|
|
|
@ -55,6 +55,13 @@ if ((isset($post_port)) && ($post_port != ""))
|
|||
|
||||
include $file_newsportal;
|
||||
include "head.inc";
|
||||
|
||||
if (disable_page_by_user_agent($client_device, "bot", "Post")) {
|
||||
echo "<center>Page Disabled</center>";
|
||||
include "tail.inc";
|
||||
exit();
|
||||
}
|
||||
|
||||
global $synchro_user, $synchro_pass;
|
||||
// check to which groups the user is allowed to post to
|
||||
$thisgroup = _rawurldecode($_REQUEST['group']);
|
||||
|
|
|
@ -20,6 +20,12 @@ if (isset($_REQUEST['data']) && $_REQUEST['data'] == '') {
|
|||
if ((! isset($_POST['key']) || ! password_verify($CONFIG['thissitekey'], $_POST['key'])) || ((strlen(trim($_REQUEST['terms'])) < 2) && ! $_REQUEST['data'])) {
|
||||
include "head.inc";
|
||||
|
||||
if (disable_page_by_user_agent($client_device, "bot", "Search")) {
|
||||
echo "<center>Page Disabled</center>";
|
||||
include "tail.inc";
|
||||
exit();
|
||||
}
|
||||
|
||||
echo '<h1 class="np_thread_headline">';
|
||||
echo '<a href="' . $file_index . '" target=' . $frame['menu'] . '>' . basename(getcwd()) . '</a> / ';
|
||||
echo 'search</h1>';
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
include $config_dir . "/scripts/rslight-lib.php";
|
||||
include $config_dir . "/gpg.conf";
|
||||
|
||||
if (file_exists($config_dir . '/cron.disable')) {
|
||||
$logfile = $logdir . '/cron.log';
|
||||
file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " cron.php disabled by semaphore: ".$config_dir . "/cron.disable Exiting...", FILE_APPEND);
|
||||
exit;
|
||||
}
|
||||
|
||||
$menulist = file($config_dir . "menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
|
||||
# Start or verify NNTP server
|
||||
|
@ -123,7 +129,8 @@ foreach($menulist as $menu) {
|
|||
rotate_keys();
|
||||
echo "Keys rotated\n";
|
||||
|
||||
function log_rotate() {
|
||||
function log_rotate()
|
||||
{
|
||||
global $logdir;
|
||||
$rotate = filemtime($logdir . '/rotate');
|
||||
if ((time() - $rotate) > 86400) {
|
||||
|
@ -146,7 +153,8 @@ function log_rotate() {
|
|||
}
|
||||
}
|
||||
|
||||
function rotate_keys() {
|
||||
function rotate_keys()
|
||||
{
|
||||
global $spooldir;
|
||||
$keyfile = $spooldir . '/keys.dat';
|
||||
$newkeys = array();
|
||||
|
@ -172,16 +180,14 @@ function rotate_keys() {
|
|||
|
||||
function change_identity($uid, $gid)
|
||||
{
|
||||
if( !posix_setgid( $gid ) )
|
||||
{
|
||||
if (! posix_setgid($gid)) {
|
||||
print "Unable to setgid to " . $gid . "!\n";
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
|
||||
if( !posix_setuid( $uid ) )
|
||||
{
|
||||
if (! posix_setuid($uid)) {
|
||||
print "Unable to setuid to " . $uid . "!\n";
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -24,6 +24,13 @@ if ((isset($_REQUEST['command']) && $_REQUEST['command'] == 'Show') && password_
|
|||
}
|
||||
$title .= ' - Browse files';
|
||||
include "head.inc";
|
||||
|
||||
if (disable_page_by_user_agent($client_device, "bot", "Files")) {
|
||||
echo "<center>Page Disabled</center>";
|
||||
include "tail.inc";
|
||||
exit();
|
||||
}
|
||||
|
||||
echo '<h1 class="np_thread_headline">';
|
||||
echo '<a href="../spoolnews/files.php" target=' . $frame['menu'] . '>files</a> / ';
|
||||
echo htmlspecialchars($_COOKIE['mail_name']) . '</h1>';
|
||||
|
|
|
@ -55,6 +55,12 @@ if ((password_verify($_POST['username'] . $keys[0] . get_user_config($_POST['use
|
|||
$title .= ' - Mail';
|
||||
include "head.inc";
|
||||
|
||||
if (disable_page_by_user_agent($client_device, "bot", "Mail")) {
|
||||
echo "<center>Page Disabled</center>";
|
||||
include "tail.inc";
|
||||
exit();
|
||||
}
|
||||
|
||||
echo '<h1 class="np_thread_headline">';
|
||||
|
||||
echo '<a href="mail.php" target=' . $frame['menu'] . '>mail</a> / ';
|
||||
|
@ -323,7 +329,13 @@ if (isset($_POST['command']) && $_POST['command'] == 'Send') {
|
|||
echo "<td></td><td><input type='submit' value='Send Mail' name='sendMessage' /></td>";
|
||||
echo '</tr></tbody></table></form>';
|
||||
}
|
||||
|
||||
view_mailbox($user);
|
||||
|
||||
// Show My Messages
|
||||
function view_mailbox($user)
|
||||
{
|
||||
global $spooldir, $offset;
|
||||
$database = $spooldir . '/mail.db3';
|
||||
$dbh = mail_db_open($database);
|
||||
echo '<hr><h1 class="np_thread_headline">My Messages:</h1>';
|
||||
|
@ -374,6 +386,7 @@ while (($row = $query->fetch()) !== false) {
|
|||
}
|
||||
echo '</tbody></table><br />';
|
||||
include "tail.inc";
|
||||
}
|
||||
|
||||
function send_external_mail($sender, $recipient, $date, $subject, $message)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
include "config.inc.php";
|
||||
include "newsportal.php";
|
||||
include("config.inc.php");
|
||||
include("newsportal.php");
|
||||
|
||||
if (isset($_COOKIE['tzo'])) {
|
||||
$offset = $_COOKIE['tzo'];
|
||||
|
@ -37,6 +37,12 @@ if ($_POST['command'] == 'Logout') {
|
|||
$title .= ' - User Configuration';
|
||||
include "head.inc";
|
||||
|
||||
if (disable_page_by_user_agent($client_device, "bot", "User")) {
|
||||
echo "<center>Page Disabled</center>";
|
||||
include "tail.inc";
|
||||
exit();
|
||||
}
|
||||
|
||||
// How long should cookie allow user to stay logged in?
|
||||
// 14400 = 4 hours
|
||||
$auth_expire = 14400;
|
||||
|
@ -76,6 +82,7 @@ if (((get_user_mail_auth_data($_COOKIE['mail_name'])) && password_verify($_POST[
|
|||
echo 'Login failed.';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['command']) && $_POST['command'] == 'Configuration') {
|
||||
echo '<h1 class="np_thread_headline">';
|
||||
echo '<a href="user.php" target=' . $frame['menu'] . '>Configuration</a> / ';
|
||||
|
|
Loading…
Reference in New Issue