Add 'subscribe' feature for groups, and config to manage
This commit is contained in:
parent
d5869313b2
commit
74f7f09fb1
|
@ -12,7 +12,11 @@
|
|||
$logfile=$logdir.'/newsportal.log';
|
||||
$accessfile=$logdir.'/access.log';
|
||||
throttle_hits();
|
||||
|
||||
if(isset($_COOKIE['mail_name'])) {
|
||||
$user = strtolower($_COOKIE['mail_name']);
|
||||
$userfile=$spooldir.'/'.$user.'-articleviews.dat';
|
||||
$userdata = unserialize(file_get_contents($userfile));
|
||||
}
|
||||
// register parameters
|
||||
$id=$_REQUEST["id"];
|
||||
$group=_rawurldecode($_REQUEST["group"]);
|
||||
|
@ -23,7 +27,7 @@
|
|||
header("Location: $newurl");
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
if(strpos($id, '@') !== false) {
|
||||
if($CONFIG['article_database'] == '1') {
|
||||
$database = $spooldir.'/articles-overview.db3';
|
||||
|
@ -54,8 +58,12 @@
|
|||
$location = $_SERVER['REQUEST_URI'].$_SERVER['REQUEST_STRING'];
|
||||
$_SESSION['return_page'] = $location.'#'.$id;
|
||||
|
||||
file_put_contents($accessfile, "\n".format_log_date()." ".$config_name." ".$group.":".$id, FILE_APPEND);
|
||||
|
||||
file_put_contents($accessfile, "\n".format_log_date()." ".$config_name." ".$group.":".$id, FILE_APPEND);
|
||||
if($user) {
|
||||
$userdata[$group] = time();
|
||||
file_put_contents($userfile, serialize($userdata));
|
||||
}
|
||||
|
||||
if(isset($frames_on) && $frames_on === true) {
|
||||
?>
|
||||
<script>
|
||||
|
|
|
@ -569,7 +569,10 @@ function groups_show($gruppen) {
|
|||
$acttype="keins";
|
||||
echo '<table class="np_groups_table" cellspacing="0"><tr class="np_thread_head"><td width="45px" class="np_thread_head">';
|
||||
echo 'Latest</td><td style="text-align: center;">Newsgroup</td><td width="8%" class="np_thread_head">Messages</td><td width="20%" class="np_thread_head" >Last Message</td></tr>';
|
||||
$subs = array();
|
||||
$nonsubs = array();
|
||||
for($i = 0 ; $i < $c ; $i++) {
|
||||
unset($groupdisplay);
|
||||
$g = $gruppen[$i];
|
||||
if(isset($g->text)) {
|
||||
if($acttype!="text") {
|
||||
|
@ -579,41 +582,50 @@ function groups_show($gruppen) {
|
|||
if($acttype!="group") {
|
||||
$acttype="group";
|
||||
}
|
||||
$user = null;
|
||||
if(isset($_COOKIE['mail_name'])) {
|
||||
$user = strtolower($_COOKIE['mail_name']);
|
||||
$userfile=$spooldir.'/'.$user.'-articleviews.dat';
|
||||
$userdata = unserialize(file_get_contents($userfile));
|
||||
}
|
||||
/* Display group name and description */
|
||||
$lineclass="np_thread_line".(($i%2)+1);
|
||||
|
||||
echo '<tr class="'.$lineclass.'"><td style="text-align: center;" class="'.$lineclass.'">';
|
||||
echo '<a href="overboard.php?thisgroup='._rawurlencode($g->name).'">';
|
||||
if(isset($userdata[$g->name])) {
|
||||
$lineclass="np_thread_line2";
|
||||
} else {
|
||||
$lineclass="np_thread_line1";
|
||||
}
|
||||
$groupdisplay = '<tr class="'.$lineclass.'"><td style="text-align: center;" class="'.$lineclass.'">';
|
||||
$groupdisplay.='<a href="overboard.php?thisgroup='._rawurlencode($g->name).'">';
|
||||
if (file_exists('../common/themes/'.$_SESSION['theme'].'/images/latest.png')) {
|
||||
$latest_image='../common/themes/'.$_SESSION['theme'].'/images/latest.png';
|
||||
} else {
|
||||
$latest_image='../common/images/latest.png';
|
||||
}
|
||||
echo '<img src="'.$latest_image.'">';
|
||||
echo '</a>';
|
||||
echo '</td>';
|
||||
$groupdisplay.='<img src="'.$latest_image.'">';
|
||||
$groupdisplay.='</a>';
|
||||
$groupdisplay.='</td>';
|
||||
|
||||
echo '<td class="'.$lineclass.'">';
|
||||
echo '<span class="np_group_line_text">';
|
||||
echo '<a ';
|
||||
echo 'target="'.$frame['content'].'" ';
|
||||
echo 'href="'.$file_thread.'?group='._rawurlencode($g->name).'"><span class="np_group_line_text">'.group_display_name($g->name)."</span></a>\n";
|
||||
$groupdisplay.='<td class="'.$lineclass.'">';
|
||||
$groupdisplay.='<span class="np_group_line_text">';
|
||||
$groupdisplay.='<a ';
|
||||
$groupdisplay.='target="'.$frame['content'].'" ';
|
||||
$groupdisplay.='href="'.$file_thread.'?group='._rawurlencode($g->name).'"><span class="np_group_line_text">'.group_display_name($g->name)."</span></a>\n";
|
||||
if($g->description!="-")
|
||||
echo '</span><br><p class="np_group_desc">'.$g->description.'</p>';
|
||||
$groupdisplay.='</span><br><p class="np_group_desc">'.$g->description.'</p>';
|
||||
|
||||
/* Display article count */
|
||||
echo '</td><td class="'.$lineclass.'">';
|
||||
$groupdisplay.='</td><td class="'.$lineclass.'">';
|
||||
if($gl_age)
|
||||
$datecolor=thread_format_date_color($g->age);
|
||||
echo '<small>';
|
||||
$groupdisplay.='<small>';
|
||||
if($datecolor!="")
|
||||
echo '<font color="'.$datecolor.'">'.$g->count.'</font>';
|
||||
$groupdisplay.='<font color="'.$datecolor.'">'.$g->count.'</font>';
|
||||
else
|
||||
echo $g->count;
|
||||
echo '</small>';
|
||||
$groupdisplay.=$g->count;
|
||||
$groupdisplay.='</small>';
|
||||
|
||||
/* Display latest article info */
|
||||
echo '</td><td class="'.$lineclass.'"><div class="np_last_posted_date">';
|
||||
$groupdisplay.='</td><td class="'.$lineclass.'"><div class="np_last_posted_date">';
|
||||
$filename = $spooldir."/".$g->name."-lastarticleinfo.dat";
|
||||
if($file=@fopen($filename,"r")) {
|
||||
$lastarticleinfo=unserialize(fread($file,filesize($filename)));
|
||||
|
@ -654,14 +666,30 @@ function groups_show($gruppen) {
|
|||
}
|
||||
}
|
||||
}
|
||||
echo get_date_interval(date("D, j M Y H:i T",$lastarticleinfo->date));
|
||||
echo '<table><tr><td>';
|
||||
echo '<font class="np_last_posted_date">by: ';
|
||||
echo create_name_link(mb_decode_mimeheader($lastarticleinfo->name));
|
||||
echo '</td></tr></table>';
|
||||
if(isset($userdata[$g->name])) {
|
||||
if($userdata[$g->name] < $lastarticleinfo->date) {
|
||||
$groupdisplay.='(<b>new</b>) ';
|
||||
}
|
||||
}
|
||||
$groupdisplay.=get_date_interval(date("D, j M Y H:i T",$lastarticleinfo->date));
|
||||
$groupdisplay.='<table><tr><td>';
|
||||
$groupdisplay.='<font class="np_last_posted_date">by: ';
|
||||
$groupdisplay.=create_name_link(mb_decode_mimeheader($lastarticleinfo->name));
|
||||
$groupdisplay.='</td></tr></table>';
|
||||
}
|
||||
echo "\n";
|
||||
$groupdisplay.="\n";
|
||||
flush();
|
||||
if(isset($userdata[$g->name])) {
|
||||
$subs[] = $groupdisplay;
|
||||
} else {
|
||||
$nonsubs[] = $groupdisplay;
|
||||
}
|
||||
} // END
|
||||
foreach($subs as $sub) {
|
||||
echo $sub;
|
||||
}
|
||||
foreach($nonsubs as $nonsub) {
|
||||
echo $nonsub;
|
||||
}
|
||||
echo "</td></div></table>\n";
|
||||
}
|
||||
|
|
|
@ -28,7 +28,11 @@
|
|||
include "$file_newsportal";
|
||||
|
||||
throttle_hits();
|
||||
|
||||
if(isset($_COOKIE['mail_name'])) {
|
||||
$user = strtolower($_COOKIE['mail_name']);
|
||||
$userfile=$spooldir.'/'.$user.'-articleviews.dat';
|
||||
$userdata = unserialize(file_get_contents($userfile));
|
||||
}
|
||||
if(isset($frames_on) && $frames_on === true) {
|
||||
?>
|
||||
<script>
|
||||
|
@ -78,6 +82,10 @@ if (isset($_GET['thisgroup'])) {
|
|||
$grouplist = array();
|
||||
$grouplist[0] = _rawurldecode(_rawurldecode($_GET['thisgroup']));
|
||||
$cachefile=$spooldir."/".$grouplist[0]."-overboard.dat";
|
||||
if($user) {
|
||||
$userdata[$grouplist[0]] = time();
|
||||
file_put_contents($userfile, serialize($userdata));
|
||||
}
|
||||
} else {
|
||||
$grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,11 @@ if(isset($_REQUEST["last"]))
|
|||
die();
|
||||
}
|
||||
|
||||
if(isset($_COOKIE['mail_name'])) {
|
||||
$user = strtolower($_COOKIE['mail_name']);
|
||||
$userfile=$spooldir.'/'.$user.'-articleviews.dat';
|
||||
$userdata = unserialize(file_get_contents($userfile));
|
||||
}
|
||||
$thread_show["latest"]=true;
|
||||
$title.= ' - '.$group;
|
||||
include "head.inc";
|
||||
|
@ -50,7 +55,11 @@ if(isset($frames_on) && $frames_on === true) {
|
|||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
if($user) {
|
||||
$userdata[$group] = time();
|
||||
file_put_contents($userfile, serialize($userdata));
|
||||
}
|
||||
|
||||
$_SESSION['return_page'] = $_SERVER['REQUEST_URI'].$_SERVER['REQUEST_STRING'];
|
||||
|
||||
echo '<a name="top"></a>';
|
||||
|
|
|
@ -117,6 +117,9 @@ echo '</table>';
|
|||
$user = strtolower($_POST['username']);
|
||||
$_SESSION['username'] = $user;
|
||||
unset($user_config);
|
||||
$userfile=$spooldir.'/'.$user.'-articleviews.dat';
|
||||
$userdata = unserialize(file_get_contents($userfile));
|
||||
ksort($userdata);
|
||||
|
||||
// Apply Config
|
||||
if(isset($_POST['command']) && $_POST['command'] == 'SaveConfig') {
|
||||
|
@ -126,6 +129,20 @@ echo '</table>';
|
|||
$user_config['theme'] = $_POST['listbox'];
|
||||
file_put_contents($config_dir.'/userconfig/'.$user.'.config', serialize($user_config));
|
||||
$_SESSION['theme'] = $user_config['theme'];
|
||||
$mysubs = explode("\n", $_POST['subscribed']);
|
||||
foreach($mysubs as $sub) {
|
||||
if(trim($sub) == '') {
|
||||
continue;
|
||||
}
|
||||
$sub = trim($sub);
|
||||
if(!isset($userdata[$sub])) {
|
||||
$userdata[$sub] = 0;
|
||||
}
|
||||
$newsubs[$sub] = $userdata[$sub];
|
||||
}
|
||||
file_put_contents($spooldir.'/'.$user.'-articleviews.dat', serialize($newsubs));
|
||||
$userdata = unserialize(file_get_contents($userfile));
|
||||
ksort($userdata);
|
||||
echo 'Configuration Saved for '.$_POST[username];
|
||||
} else {
|
||||
$user_config = unserialize(file_get_contents($config_dir.'/userconfig/'.$user.'.config'));
|
||||
|
@ -144,6 +161,7 @@ echo '</table>';
|
|||
}
|
||||
}
|
||||
sort($themes);
|
||||
|
||||
// Show Config
|
||||
echo '<hr><h1 class="np_thread_headline">Configuration:</h1>';
|
||||
echo '<table cellspacing="0" width="100%" class="np_results_table">';
|
||||
|
@ -174,6 +192,14 @@ echo '</table>';
|
|||
echo '</select>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
// Subscriptions
|
||||
echo '<td class="np_result_line1" style="word-wrap:break-word";>Subscribed:</td>';
|
||||
echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word";><textarea class="configuration" id="subscribed" name="subscribed" rows="10" cols="40">';
|
||||
foreach($userdata as $key => $value) {
|
||||
echo $key."\n";
|
||||
}
|
||||
echo '</textarea></td>';
|
||||
echo '</tr>';
|
||||
/*
|
||||
// Timezone
|
||||
echo '<td class="np_result_line1" style="word-wrap:break-word";>Timezone offset (+/- hours from UTC):</td>';
|
||||
|
@ -182,6 +208,7 @@ echo '</table>';
|
|||
*/
|
||||
echo '<td class="np_result_line2" style="word-wrap:break-word";>';
|
||||
echo '<button class="np_button_link" type="submit">Save Configuration</button>';
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'">Cancel</a>';
|
||||
echo '</td></tr>';
|
||||
echo '<input name="command" type="hidden" id="command" value="SaveConfig" readonly="readonly">';
|
||||
echo '</form>';
|
||||
|
|
Loading…
Reference in New Issue