{"id":22325909,"url":"https://github.com/jamesbriggs/maintenance_banner","last_synced_at":"2025-08-17T05:05:17.263Z","repository":{"id":84299352,"uuid":"120263005","full_name":"jamesbriggs/maintenance_banner","owner":"jamesbriggs","description":"Administrative web UI for maintenance events to be displayed on your web application post-login page","archived":false,"fork":false,"pushed_at":"2018-02-08T06:28:18.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-17T05:02:52.081Z","etag":null,"topics":["admin-dashboard","admin-tool","admin-ui","banner","maintenance-banner","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamesbriggs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-05T06:15:32.000Z","updated_at":"2018-02-06T11:42:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"31cabb9e-3d65-4078-8127-3d98a2485353","html_url":"https://github.com/jamesbriggs/maintenance_banner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jamesbriggs/maintenance_banner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fmaintenance_banner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fmaintenance_banner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fmaintenance_banner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fmaintenance_banner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamesbriggs","download_url":"https://codeload.github.com/jamesbriggs/maintenance_banner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fmaintenance_banner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270807934,"owners_count":24649346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admin-dashboard","admin-tool","admin-ui","banner","maintenance-banner","php"],"created_at":"2024-12-04T02:14:23.618Z","updated_at":"2025-08-17T05:05:17.202Z","avatar_url":"https://github.com/jamesbriggs.png","language":"PHP","readme":"# Maintenance Banner\n\nMaintenance Banner (mx_banner.php) is a single-file 300-line PHP administrative web application to update banner settings in a database for your user web application to SELECT and display.\n\nIt is useful when managing production web applications to inform users of scheduled maintenance by showing a banner to users immediately upon login or homepage refresh.\n\nFrom an SRE perspective, as you achieve availability levels above 3x9's, it becomes more important to inform users of even brief interruptions and to coordinate maintenance windows.\n\nmx_banner.php is also a minimal but non-trivial CRUD application that illustrates secure programming with PHP using database placeholders (?) and strip_tags().\n\n## Screenshots\n\n![mx_banner list of events](https://github.com/jamesbriggs/maintenance_banner/blob/master/docs/mx_banner.png)\n![user application displaying event](https://github.com/jamesbriggs/maintenance_banner/blob/master/docs/mx_banner_user.png)\n\n## Dependencies:\n\nRequires the PHP PDO database library for either MySQL or Postgresql:\n\n   On CentOS as root:\n\n```bash\nyum install php-pgsql\nyum install php-mysql\nservice httpd restart\n```\n\n   On Ubuntu or Debian as root:\n\n```bash\napt-get update\napt-get install php-pgsql\napt-get install php-mysql\n/etc/init.d/apache2 restart\n```\n\n\n## Admin Installation:\n\n1. copy mx_banner.php into a directory with PHP enabled and preferably SSL with a password, like Basic Authentication. (The directory should be for internal use only.)\n2. set permissions:\n\n```bash\nchown root:root mx_banner.php\nchmod 755 mx_banner.php\n```\n\n3. edit mx_banner.php and configure the user settings for your database, which can be local or remote.\n4. create the intercom table schema using mx_banner_mysql.sql or mx_banner_pgsql.sql\n\n   For MySQL, schema creation is as simple as:\n\n```bash\nmysql -h host_name -u root -p database_name \u003c mx_banner_mysql.sql\n```\n\n   For Postgresql, schema creation is more complicated since sequences and roles are required.\n\n   I'd recommend asking your DBA to do the schema creation, or use pgloader, or pgAdmin and manually do the setup while looking at mx_banner_pgsql.sql.\n\n5. if it doesn't seem to work and no errors are displayed, edit /etc/php.ini and set `display_errors=on` and restart your web server.\n\n## Troubleshooting:\n\na. To check for program syntax errors from the command line, type:\n\n```bash\nphp -l mx_banner.php\nNo syntax errors detected in mx_banner.php\n```\n\nb. To manually insert test data into the database:\n```sql\ninsert into intercom (dt_start, dt_end, message, type) values ('2018-01-11 14:17:03', '2018-02-27 00:00:00', 'Test message.', 'notice');\n```\n\n## User Application Installation:\n\n1. Add an HTML div somewhere on your post-login page\n2. Have your application make the following SQL query (using any programming language, not only PHP) and write the results into the div from step 1:\n\n```sql\nselect id, dt_start, dt_end, message, type from intercom where dt_start \u003c= now() and dt_end \u003e= now() order by dt_start;\n```\n\n   In a PHP or Perl here-document:\n\n```html\n\u003cdiv class=\"$type\"\u003e\n\u003cp\u003e$message\u003c/p\u003e\n\u003cp\u003e$dt_start - $dt_end\u003c/p\u003e\n\u003c/div\u003e\n```\n\n3. You can use the type column as the CSS class to set each banner's color and icon. There are 4 values: `notice, warning, success and error.`\n\n## Upgrades\n\nmx_banner.php is a single-file application, so future upgrades are very simple - just copy the new version over the old file and adjust the permissions as required.\n\n## License\n\nApache 2.0 License\n\n## Copyright\n\nJames Briggs, USA 2018.\n\nYou may use Maintenance Banner on a non-exclusive basis and re-distribute in your own work. I provide no guarantee and assume no liability for your use of this program.\n\n## Contact\n\nPlease create a Github issue with any improvements or security issues.\n\n## Todo\n\n- JavaScript input validation could be fancier.\n- Security is always evolving in web programs.\n- The PHP PDO Postgresql date range error exception is not raised for some reason.\n- The Postgresql create table script could be simplified.\n- Actual sample code for user application integration in several programming languages.\n- Could include pre-made CSS and icons for quicker deployment setup, like the Clarity icons: https://vmware.github.io/clarity/icons/icon-sets#core-shapes\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesbriggs%2Fmaintenance_banner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamesbriggs%2Fmaintenance_banner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesbriggs%2Fmaintenance_banner/lists"}