Move fortunes config to file in config dir.
This commit is contained in:
parent
00c537acfa
commit
2676176737
|
@ -1,5 +1,5 @@
|
|||
<html>
|
||||
<head>
|
||||
<head>
|
||||
<?php
|
||||
if (basename(getcwd()) == 'mods') {
|
||||
$rootdir = "../../";
|
||||
|
@ -7,7 +7,7 @@ if (basename(getcwd()) == 'mods') {
|
|||
$rootdir = "../";
|
||||
}
|
||||
|
||||
include($rootdir.'common/config.inc.php');
|
||||
include ($rootdir . 'common/config.inc.php');
|
||||
|
||||
$CONFIG = include $config_file;
|
||||
?>
|
||||
|
@ -17,154 +17,136 @@ $CONFIG = include $config_file;
|
|||
</script>
|
||||
<?php
|
||||
|
||||
$menulist = file($config_dir."menu.conf", FILE_IGNORE_NEW_LINES);
|
||||
$linklist = file($config_dir."links.conf", FILE_IGNORE_NEW_LINES);
|
||||
$menulist = file($config_dir . "menu.conf", FILE_IGNORE_NEW_LINES);
|
||||
$linklist = file($config_dir . "links.conf", FILE_IGNORE_NEW_LINES);
|
||||
|
||||
if(isset($_COOKIE['mail_name']) && isset($_COOKIE['pkey'])) {
|
||||
if (isset($_COOKIE['mail_name']) && isset($_COOKIE['pkey'])) {
|
||||
$user = strtolower($_COOKIE['mail_name']);
|
||||
if(!isset($_SESSION['theme']) && file_exists($config_dir.'/userconfig/'.$user.'.config')) {
|
||||
$user_config = unserialize(file_get_contents($config_dir.'/userconfig/'.$user.'.config'));
|
||||
if (! isset($_SESSION['theme']) && file_exists($config_dir . '/userconfig/' . $user . '.config')) {
|
||||
$user_config = unserialize(file_get_contents($config_dir . '/userconfig/' . $user . '.config'));
|
||||
$_SESSION['theme'] = $user_config['theme'];
|
||||
}
|
||||
} else {
|
||||
unset($user);
|
||||
}
|
||||
|
||||
if(isset($_SESSION['theme'])) {
|
||||
//if(trim($_SESSION['theme']) !== '') {
|
||||
echo '<link rel="stylesheet" type="text/css" href="../common/themes/'.$_SESSION['theme'].'/style.css">';
|
||||
if (isset($_SESSION['theme'])) {
|
||||
// if(trim($_SESSION['theme']) !== '') {
|
||||
echo '<link rel="stylesheet" type="text/css" href="../common/themes/' . $_SESSION['theme'] . '/style.css">';
|
||||
} else {
|
||||
echo '<link rel="stylesheet" type="text/css" href="'.$rootdir.'common/themes/Default Theme/style.css">';
|
||||
echo '<link rel="stylesheet" type="text/css" href="' . $rootdir . 'common/themes/Default Theme/style.css">';
|
||||
}
|
||||
|
||||
if ((isset($_SESSION['theme'])) && file_exists($rootdir.'common/themes/'.$_SESSION['theme'].'/images/rocksolidlight.png')) {
|
||||
$header_image=$rootdir.'common/themes/'.$_SESSION['theme'].'/images/rocksolidlight.png';
|
||||
if ((isset($_SESSION['theme'])) && file_exists($rootdir . 'common/themes/' . $_SESSION['theme'] . '/images/rocksolidlight.png')) {
|
||||
$header_image = $rootdir . 'common/themes/' . $_SESSION['theme'] . '/images/rocksolidlight.png';
|
||||
} else {
|
||||
$header_image=$rootdir.'common/images/rocksolidlight.png';
|
||||
$header_image = $rootdir . 'common/images/rocksolidlight.png';
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<table class="np_header_bar_top" width="100%" valign="middle">
|
||||
<body>
|
||||
<table class="np_header_bar_top" width="100%" valign="middle">
|
||||
<tr>
|
||||
<td width="30%">
|
||||
<a href="<?php echo $CONFIG['default_content'];?>"><img src="<?php echo $header_image ?>" alt="Rocksolid Light" class="responsive_image"></a>
|
||||
</td>
|
||||
<td width="30%"><a href="<?php echo $CONFIG['default_content'];?>"><img
|
||||
src="<?php echo $header_image ?>" alt="Rocksolid Light"
|
||||
class="responsive_image"></a></td>
|
||||
<td>
|
||||
|
||||
|
||||
<p align="left"><small>
|
||||
<font class="np_title">
|
||||
<p align="left">
|
||||
<small> <font class="np_title">
|
||||
<?php echo $CONFIG['rslight_title']; ?>
|
||||
</font>
|
||||
</small></p>
|
||||
</small>
|
||||
</p>
|
||||
</td>
|
||||
<td align="right">
|
||||
<?php
|
||||
if(isset($user) && $user && check_unread_mail() == true) {
|
||||
if (isset($user) && $user && check_unread_mail() == true) {
|
||||
$unread = true;
|
||||
} else {
|
||||
} else {
|
||||
$unread = false;
|
||||
}
|
||||
foreach($linklist as $link) {
|
||||
if($link[0] == '#') {
|
||||
}
|
||||
foreach ($linklist as $link) {
|
||||
if ($link[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
$linkitem=explode(':', $link, 2);
|
||||
if($linkitem[1] == '0') {
|
||||
$linkitem = explode(':', $link, 2);
|
||||
if ($linkitem[1] == '0') {
|
||||
continue;
|
||||
}
|
||||
if($unread && (strpos($linkitem[1], 'spoolnews/mail.php') !== false)) {
|
||||
if ($unread && (strpos($linkitem[1], 'spoolnews/mail.php') !== false)) {
|
||||
echo '<strong>';
|
||||
echo '<a class="np_header_links" href="'.trim($linkitem[1]).'">'.trim(strtoupper($linkitem[0])).'</a>  ';
|
||||
echo '<a class="np_header_links" href="' . trim($linkitem[1]) . '">' . trim(strtoupper($linkitem[0])) . '</a>  ';
|
||||
echo '</strong>';
|
||||
} else {
|
||||
echo '<a class="np_header_links" href="'.trim($linkitem[1]).'">'.trim($linkitem[0]).'</a>  ';
|
||||
echo '<a class="np_header_links" href="' . trim($linkitem[1]) . '">' . trim($linkitem[0]) . '</a>  ';
|
||||
}
|
||||
}
|
||||
echo '<a class="np_header_links" href="../spoolnews/user.php">';
|
||||
if(isset($user)) {
|
||||
echo '('.$_COOKIE['mail_name'].')';
|
||||
} else {
|
||||
}
|
||||
echo '<a class="np_header_links" href="../spoolnews/user.php">';
|
||||
if (isset($user)) {
|
||||
echo '(' . $_COOKIE['mail_name'] . ')';
|
||||
} else {
|
||||
echo 'login';
|
||||
}
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</a>';
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
// You can display fortunes if you have fortune installed. This is disabled by default
|
||||
$display_fortunes = true;
|
||||
|
||||
if($display_fortunes) {
|
||||
ob_start();
|
||||
|
||||
// Select fortunes
|
||||
// If you want different fortunes for different sections you can do that here
|
||||
if(!isset($config_name)) {
|
||||
$config_name = null;
|
||||
}
|
||||
if($config_name == 'computers' || $config_name == 'programming') {
|
||||
passthru('/usr/games/fortune -s -n 100 linux debian perl linuxcookie computers');
|
||||
} else if ($config_name == 'arts' || $config_name == 'interests') {
|
||||
passthru('/usr/games/fortune -s -n 100 art magic tao cookie songs-poems work food miscellaneous literature pets science wisdom');
|
||||
} else if ($config_name =='sport') {
|
||||
passthru('/usr/games/fortune -s -n 100 sports');
|
||||
} else {
|
||||
passthru('/usr/games/fortune -s -n 100');
|
||||
}
|
||||
$motd = ob_get_contents();
|
||||
$motd = htmlentities($motd);
|
||||
ob_end_clean();
|
||||
}
|
||||
include($config_dir.'/fortunes.conf');
|
||||
|
||||
// If $config_dir/motd.txt is not blank, show it
|
||||
if(file_exists($config_dir.'/motd.txt')) {
|
||||
$motd = file_get_contents($config_dir.'/motd.txt');
|
||||
if (file_exists($config_dir . '/motd.txt')) {
|
||||
$motd = file_get_contents($config_dir . '/motd.txt');
|
||||
}
|
||||
echo '<p align="center" class="np_header_button_bar">';
|
||||
echo '<table cellpadding="0" cellspacing="0"><tr>';
|
||||
foreach($menulist as $menu) {
|
||||
if($menu[0] == '#') {
|
||||
foreach ($menulist as $menu) {
|
||||
if ($menu[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
$menuitem=explode(':', $menu);
|
||||
if($menuitem[1] == '0') {
|
||||
$menuitem = explode(':', $menu);
|
||||
if ($menuitem[1] == '0') {
|
||||
continue;
|
||||
}
|
||||
if(!isset($frame['menu'])) {
|
||||
if (! isset($frame['menu'])) {
|
||||
$frame['menu'] = null;
|
||||
}
|
||||
echo '<td>';
|
||||
echo '<form target="'.$frame['menu'].'" action="'.$rootdir.$menuitem[0].'">';
|
||||
echo '<button class="np_header_button_link" type="submit">'.$menuitem[0].'</button>';
|
||||
echo '<form target="' . $frame['menu'] . '" action="' . $rootdir . $menuitem[0] . '">';
|
||||
echo '<button class="np_header_button_link" type="submit">' . $menuitem[0] . '</button>';
|
||||
echo '</form>';
|
||||
echo '</td>';
|
||||
}
|
||||
echo '</tr></table></p><p>';
|
||||
echo '</tr></table></p><p>';
|
||||
echo '<table cellpadding="0" cellspacing="0" class="np_header_bar_small"><tr>';
|
||||
if($unread) {
|
||||
if ($unread) {
|
||||
$motd = '<center>*** You have unread mail. <a href="../spoolnews/mail.php">Click Here</a> ***</center>';
|
||||
}
|
||||
if(strlen($motd) > 0) {
|
||||
echo '<div class="np_last_posted_date"><h1 class="np_thread_headline">'.$motd.'</h1></div>';
|
||||
}
|
||||
echo '</tr></table>';
|
||||
echo '</p>';
|
||||
function check_unread_mail() {
|
||||
if (strlen($motd) > 0) {
|
||||
echo '<div class="np_last_posted_date"><h1 class="np_thread_headline">' . $motd . '</h1></div>';
|
||||
}
|
||||
echo '</tr></table>';
|
||||
echo '</p>';
|
||||
|
||||
function check_unread_mail()
|
||||
{
|
||||
global $CONFIG, $spooldir;
|
||||
if(isset($_COOKIE['mail_name'])) {
|
||||
if (isset($_COOKIE['mail_name'])) {
|
||||
$name = strtolower($_COOKIE['mail_name']);
|
||||
$database = $spooldir.'/mail.db3';
|
||||
if(is_file($database)) {
|
||||
$database = $spooldir . '/mail.db3';
|
||||
if (is_file($database)) {
|
||||
$dbh = head_mail_db_open($database);
|
||||
$query = $dbh->prepare('SELECT * FROM messages where rcpt_to=:rcpt_to');
|
||||
$query->execute(['rcpt_to' => $name]);
|
||||
$query->execute([
|
||||
'rcpt_to' => $name
|
||||
]);
|
||||
$newmail = false;
|
||||
while (($row = $query->fetch()) !== false) {
|
||||
if(($row['rcpt_viewed'] != 'true') && ($row['to_hide'] !='true')) {
|
||||
if (($row['rcpt_viewed'] != 'true') && ($row['to_hide'] != 'true')) {
|
||||
$newmail = true;
|
||||
}
|
||||
}
|
||||
|
@ -176,12 +158,13 @@ function check_unread_mail() {
|
|||
}
|
||||
}
|
||||
|
||||
function head_mail_db_open($database, $table='messages') {
|
||||
function head_mail_db_open($database, $table = 'messages')
|
||||
{
|
||||
try {
|
||||
$dbh = new PDO('sqlite:'.$database);
|
||||
$dbh = new PDO('sqlite:' . $database);
|
||||
} catch (PDOExeption $e) {
|
||||
echo 'Connection failed: '.$e->getMessage();
|
||||
exit;
|
||||
echo 'Connection failed: ' . $e->getMessage();
|
||||
exit();
|
||||
}
|
||||
$dbh->exec("CREATE TABLE IF NOT EXISTS messages(
|
||||
id INTEGER PRIMARY KEY,
|
||||
|
@ -196,7 +179,8 @@ function head_mail_db_open($database, $table='messages') {
|
|||
message TEXT,
|
||||
from_hide TEXT,
|
||||
to_hide TEXT)");
|
||||
return($dbh);
|
||||
return ($dbh);
|
||||
}
|
||||
?>
|
||||
</body></html>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/* This file is an example. Modify to match your system
|
||||
* The fortunes package must be installed for this to work
|
||||
* $enable_fortunes will enable or disable display of 'fortunes' in the header
|
||||
*/
|
||||
$enable_fortunes = true;
|
||||
|
||||
/* Creating a file: $config_dir.'/motd.txt' will override fortunes and display the file contents. */
|
||||
|
||||
if($enable_fortunes == true) {
|
||||
ob_start();
|
||||
|
||||
if(!isset($config_name)) {
|
||||
$config_name = null;
|
||||
}
|
||||
|
||||
if($config_name == 'computers' || $config_name == 'programming') {
|
||||
passthru('/usr/games/fortune -s -n 100 linux science debian perl linuxcookie cookie computers startrek math.fortunes');
|
||||
} else if ($config_name == 'arts' || $config_name == 'interests') {
|
||||
passthru('/usr/games/fortune -s -n 100 fortunes education people platitudes art magic wisdom tao cookie songs-poems work food miscellaneous literature pets science wisdom');
|
||||
} else if ($config_name =='sport') {
|
||||
passthru('/usr/games/fortune -s -n 100 sports');
|
||||
} else {
|
||||
passthru('/usr/games/fortune -s -n 100');
|
||||
}
|
||||
|
||||
$motd = ob_get_contents();
|
||||
$motd = htmlentities($motd);
|
||||
ob_end_clean();
|
||||
}
|
Loading…
Reference in New Issue