Klaus Mouse Posted November 23 Posted November 23 Does Invision Community allow me to enable "Observe Shabbat" feature that turns the forums offline from Friday 7:30PM to Saturday at 7:30PM? To implement this, I created a file in my /var/www/ips/ directory called shabbat.php. <?php header('Content-Type: text/html; charset=utf-8'); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); date_default_timezone_set('America/New_York'); error_log("Shabbat script called!"); // Prevent recursive execution by setting a custom header if (!empty($_SERVER['HTTP_X_SHABBAT_CHECK'])) { return; // Exit if this header is already set } header('X-Shabbat-Check: true'); // Function to get correct Hebrew date function getHebrewDate() { // Get current timestamp in NY timezone $date = new DateTime('now', new DateTimeZone('America/New_York')); // Convert to Julian day $jd = gregoriantojd($date->format('m'), $date->format('d'), $date->format('Y')); // Get Hebrew date components using cal_from_jd which gives more detailed information $hebrew_date = cal_from_jd($jd, CAL_JEWISH); // Correct Hebrew month names mapped to their numerical values $hebrew_months = [ 1 => 'Tishri', 2 => 'Heshvan', 3 => 'Kislev', 4 => 'Tevet', 5 => 'Shevat', 6 => 'Adar', 7 => 'Adar II', 8 => 'Nisan', 9 => 'Iyar', 10 => 'Sivan', 11 => 'Tammuz', 12 => 'Av', 13 => 'Elul' ]; // Format the date return sprintf("%d %s %d", $hebrew_date['day'], $hebrew_months[$hebrew_date['month']], $hebrew_date['year'] ); } // Get the current time and day $current_time = new DateTime(); $friday_730pm = (new DateTime('friday this week 19:30'))->setTimezone(new DateTimeZone('America/New_York')); $saturday_730pm = (new DateTime('saturday this week 19:30'))->setTimezone(new DateTimeZone('America/New_York')); // Determine if it's Shabbat if ($current_time >= $friday_730pm && $current_time < $saturday_730pm) { $remaining_time = $saturday_730pm->getTimestamp() - $current_time->getTimestamp(); $end_date = $saturday_730pm->format('l, F j, Y'); // Get current Hebrew date $current_hebrew_date = getHebrewDate(); // Display the Shabbat page ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Shabbat Shalom</title> <style> body { background-color: #2F4F4F; /* Slate Steel Gray */ color: #2C2C2C; /* Noir Graphite Dark Gray */ font-family: Arial, sans-serif; display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; margin: 0; } .container { background-color: rgba(255, 255, 255, 0.9); padding: 2rem; border-radius: 10px; text-align: center; box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); max-width: 600px; width: 90%; } .countdown { font-size: 2rem; margin: 1rem 0; font-weight: bold; } h1 { margin-top: 0; } </style> <script> function startCountdown(seconds) { const countdownElem = document.getElementById('countdown'); function updateCountdown() { const days = Math.floor(seconds / 86400); const hours = Math.floor((seconds % 86400) / 3600); const minutes = Math.floor((seconds % 3600) / 60); const secs = seconds % 60; countdownElem.textContent = `${String(days).padStart(2, '0')}d ` + `${String(hours).padStart(2, '0')}h ` + `${String(minutes).padStart(2, '0')}m ` + `${String(secs).padStart(2, '0')}s`; if (seconds > 0) { seconds--; setTimeout(updateCountdown, 1000); } } updateCountdown(); } document.addEventListener('DOMContentLoaded', () => { const remainingTime = <?php echo $remaining_time; ?>; startCountdown(remainingTime); }); </script> </head> <body> <div class="container"> <h1>SHABBAT SHALOM!</h1> <p>Our community is honoring Yeshua's Sabbath for Shabbat.</p> <p>Our site will be back online in:</p> <div class="countdown" id="countdown"></div> <p>We will reopen at 7:30pm on <?php echo $end_date; ?>.</p> <p>Current Date: <?php echo $current_hebrew_date; ?></p> </div> </body> </html> <?php exit; } // If not Shabbat, the script will proceed here. ?> However this requires me to modify the index.php script like so: <?php require_once 'shabbat.php'; /** * @brief Public bootstrap * @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a> * @copyright (c) Invision Power Services, Inc. * @license https://www.invisioncommunity.com/legal/standards/ * @package Invision Community * @since 18 Feb 2013 */ \define('REPORT_EXCEPTIONS', TRUE); $_SERVER['SCRIPT_FILENAME'] = __FILE__; require_once 'init.php'; \IPS\Dispatcher\Front::i()->run(); But that yields an error in the Admin CP: To comply with this request would mean that my forum cannot observe the Sabbath and I require this functionality for religious observance of the community that I am maintaining.
Jim M Posted November 23 Posted November 23 We do not support or recommend editing the core files of our software. Why not just turn your community offline in the ACP? This requires no code or customization. This can be done in ACP > System > General Configuration
Klaus Mouse Posted November 23 Author Posted November 23 That's very manual. Any way to automate that?
All Astronauts Posted November 23 Posted November 23 39 minutes ago, Klaus Mouse said: Any way to automate that? Plugin/App with a task that runs hourly would do it. For "reasons" imma gonna @Esther E. <whistles while walking away...>
Klaus Mouse Posted November 23 Author Posted November 23 32 minutes ago, All Astronauts said: Plugin/App with a task that runs hourly would do it. For "reasons" imma gonna @Esther E. <whistles while walking away...> I'd be happy to hire somebody who would be able to provide a plugin/app that would provide this functionality that will be compatible with both IPS 4 and IPS 5 so that when our community upgrades next year, the plugin will be compatible. I am perfectly happy with hiring somebody for building this. I will entertain thoughts/contributions from others on this, and I'd also like permission from whomever does help with this, to make the plugin/code free and open-source for others to observe the Sabbath on their IPS Communities. For religious communities, this is a gating factor that has led multiple organizations away from IPS and as somebody whose advocated for the software to new organizations that are looking for what it provides; this factor has been vocalized and raised in concern with me; thus why I wrote the script to address it for them; but the ToS are clear and its not an IPS approved way of doing it; thus why I am reaching out for support here. Thank you again, and I think this will help align IPS Community with YeHoVah and who knows... amazing blessings may come from it because sometimes its as simple as ask and you shall receive, right?
Esther E. Posted November 23 Posted November 23 3 hours ago, Klaus Mouse said: I'd be happy to hire somebody who would be able to provide a plugin/app that would provide this functionality that will be compatible with both IPS 4 and IPS 5 so that when our community upgrades next year, the plugin will be compatible. I am perfectly happy with hiring somebody for building this. I will entertain thoughts/contributions from others on this, and I'd also like permission from whomever does help with this, to make the plugin/code free and open-source for others to observe the Sabbath on their IPS Communities. For religious communities, this is a gating factor that has led multiple organizations away from IPS and as somebody whose advocated for the software to new organizations that are looking for what it provides; this factor has been vocalized and raised in concern with me; thus why I wrote the script to address it for them; but the ToS are clear and its not an IPS approved way of doing it; thus why I am reaching out for support here. Thank you again, and I think this will help align IPS Community with YeHoVah and who knows... amazing blessings may come from it because sometimes its as simple as ask and you shall receive, right? It could be accomplished with a plugin on the dispatcher, which would just check the time and then show an error message. That said, 7:30-7:30 isn't entirely accurate - if anything it would be 7:30pm Friday - 8:30 pm Saturday, and it wouldn't be applicable throughout the year; you'd need to integrate with an API, such as myzmanim.com, or something similar. Literally the only site I've ever heard of that shuts down for Shabbat is B & H. Beyond that... I'm relatively certain (not 100%, but I did look into it when I used to have files on the marketplace) that halachically it's permissible to have your website open (and even earning money), as you cannot control the actions of your user base, nor are you responsible for them. Orthodox Yeshiva education rearing its head. 😉 Torah talk aside.... whoever you hire to build this for v4 will still need to update it for v5. The entire architecture is different; there is no way to create something that will be compatible with both. Hatsu 1
Solution Klaus Mouse Posted November 24 Author Solution Posted November 24 17 hours ago, Esther E. said: It could be accomplished with a plugin on the dispatcher, which would just check the time and then show an error message. That said, 7:30-7:30 isn't entirely accurate - if anything it would be 7:30pm Friday - 8:30 pm Saturday, and it wouldn't be applicable throughout the year; you'd need to integrate with an API, such as myzmanim.com, or something similar. Literally the only site I've ever heard of that shuts down for Shabbat is B & H. Beyond that... I'm relatively certain (not 100%, but I did look into it when I used to have files on the marketplace) that halachically it's permissible to have your website open (and even earning money), as you cannot control the actions of your user base, nor are you responsible for them. Orthodox Yeshiva education rearing its head. 😉 Torah talk aside.... whoever you hire to build this for v4 will still need to update it for v5. The entire architecture is different; there is no way to create something that will be compatible with both. Oh, good catch on the 8:30PM vs 7:30PM. Thank you. Total oversight on my part. I spoke with Yeshua and I received a little more clarification on this request and how I can accomplish what I need without a plugin and nor without violating the ToS, but rather relying on the servers' configuration itself to isolate what is IPS and what is Shabbat script; thus... this reply will mark this as resolved. I thank everyone who contributed to the conversation as it helped me arrive to this solution to share with all. In /var/www/html/.htaccess I modified the DirectoryIndex property to shabbat.php and at the end of shabbat.php I added a header("Location: index.php"); and voila, IPS admin is not upset about the software and the directory is sufficient; however the line I needed to add was: DirectoryIndex shabbat.php index.php index.html index.htm After that, IPS software's index.php is restored and untouched, and the Shabbat script prohibits access to the IPS software during the window of time required. Thank you again for clarifying the 7:30PM vs 8:30PM. Here is the complete .htaccess file: DirectoryIndex shabbat.php index.php index.html index.htm <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map|webp)(\?|$) /404error.php [L,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Here is the shabbat.php script: <?php if(isset($_GET['debug']) && $_GET['debug'] == "1"){ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); } date_default_timezone_set('America/New_York'); function getHebrewDate() { $date = new DateTime('now', new DateTimeZone('America/New_York')); $jd = gregoriantojd($date->format('m'), $date->format('d'), $date->format('Y')); $hebrew_date = cal_from_jd($jd, CAL_JEWISH); $hebrew_months = [ 1 => 'Tishri', 2 => 'Heshvan', 3 => 'Kislev', 4 => 'Tevet', 5 => 'Shevat', 6 => 'Adar', 7 => 'Adar II', 8 => 'Nisan', 9 => 'Iyar', 10 => 'Sivan', 11 => 'Tammuz', 12 => 'Av', 13 => 'Elul' ]; return sprintf("%d %s %d", $hebrew_date['day'], $hebrew_months[$hebrew_date['month']], $hebrew_date['year'] ); } $current_time = new DateTime(); $friday_730pm = (new DateTime('friday this week 19:30'))->setTimezone(new DateTimeZone('America/New_York')); $saturday_830pm = (new DateTime('saturday this week 20:30'))->setTimezone(new DateTimeZone('America/New_York')); if ($current_time >= $friday_730pm && $current_time < $saturday_830pm) { if (!empty($_SERVER['HTTP_X_SHABBAT_CHECK'])) { return; // Exit if this header is already set } header('X-Shabbat-Check: true'); header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Expires: Thu, 01 Jan 1970 00:00:00 GMT'); header('Content-Type: text/html; charset=utf-8'); $remaining_time = $saturday_830pm->getTimestamp() - $current_time->getTimestamp(); $end_date = $saturday_830pm->format('l, F j, Y'); $current_hebrew_date = getHebrewDate(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Shabbat Shalom</title> <style> body { background-color: #2F4F4F; /* Slate Steel Gray */ color: #2C2C2C; /* Noir Graphite Dark Gray */ font-family: Arial, sans-serif; display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; margin: 0; } .container { background-color: rgba(255, 255, 255, 0.9); padding: 2rem; border-radius: 10px; text-align: center; box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); max-width: 600px; width: 90%; } .countdown { font-size: 2rem; margin: 1rem 0; font-weight: bold; } h1 { margin-top: 0; } </style> <script> function startCountdown(seconds) { const countdownElem = document.getElementById('countdown'); function updateCountdown() { const days = Math.floor(seconds / 86400); const hours = Math.floor((seconds % 86400) / 3600); const minutes = Math.floor((seconds % 3600) / 60); const secs = seconds % 60; countdownElem.textContent = `${String(days).padStart(2, '0')}d ` + `${String(hours).padStart(2, '0')}h ` + `${String(minutes).padStart(2, '0')}m ` + `${String(secs).padStart(2, '0')}s`; if (seconds > 0) { seconds--; setTimeout(updateCountdown, 1000); } } updateCountdown(); } document.addEventListener('DOMContentLoaded', () => { const remainingTime = <?php echo $remaining_time; ?>; startCountdown(remainingTime); }); </script> </head> <body> <div class="container"> <h1>SHABBAT SHALOM!</h1> <p>Our community is honoring Yeshua's Sabbath for Shabbat.</p> <p>Our site will be back online in:</p> <div class="countdown" id="countdown"></div> <p>We will reopen at 8:30pm on <?php echo $end_date; ?>.</p> <p>Current Date: <?php echo $current_hebrew_date; ?></p> </div> </body> </html> <?php exit; } else { header("Location: index.php"); } I believe this solution will work when IPS 5 is released as well, thus this solution is "future-proof" until the PHP syntax itself changes and the script needs to be adjusted for PHP 9 or PHP X whenever that comes out. Shalom! ~Andrei DawPi and Esther E. 2
Recommended Posts