Move fortunes config to file in config dir.
This commit is contained in:
parent
00c537acfa
commit
2676176737
|
@ -47,17 +47,18 @@ if ((isset($_SESSION['theme'])) && file_exists($rootdir.'common/themes/'.$_SESSI
|
|||
<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
|
||||
|
@ -95,30 +96,7 @@ if ((isset($_SESSION['theme'])) && file_exists($rootdir.'common/themes/'.$_SESSI
|
|||
</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')) {
|
||||
|
@ -153,7 +131,9 @@ if($unread) {
|
|||
}
|
||||
echo '</tr></table>';
|
||||
echo '</p>';
|
||||
function check_unread_mail() {
|
||||
|
||||
function check_unread_mail()
|
||||
{
|
||||
global $CONFIG, $spooldir;
|
||||
if (isset($_COOKIE['mail_name'])) {
|
||||
$name = strtolower($_COOKIE['mail_name']);
|
||||
|
@ -161,7 +141,9 @@ function check_unread_mail() {
|
|||
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')) {
|
||||
|
@ -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);
|
||||
} catch (PDOExeption $e) {
|
||||
echo 'Connection failed: ' . $e->getMessage();
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
$dbh->exec("CREATE TABLE IF NOT EXISTS messages(
|
||||
id INTEGER PRIMARY KEY,
|
||||
|
@ -199,4 +182,5 @@ function head_mail_db_open($database, $table='messages') {
|
|||
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