Dynamic Status Page For Discord Bot Using Uptime Robot API

Project URL: https://discord-status-page.glitch.me
Edit Project: https://glitch.com/edit/#!/discord-status-page

A dynamic website status page, showing uptime/downtime statistics for your Discord bot (and also websites!). This makes use of the Uptime Robot API for monitoring. [Made using PHP]

What you need? Remix this project and a monitor-specific API key generated by Uptime Robot for the bot that you want the status to be shown. Copy the token and paste it in line 4 of monitoring.php!

All suggestions are welcome and please report any bugs you find!

Thanks to @tasha and @J-Tech-Foundation for helping me in using PHP!

EDIT: Does anyone know how to store secrets in PHP, because .env doesn’t work and monitor-specific API keys can be misused!

EDITT: This project code is not by me, I was just following a tutorial at https://stevencotterill.com/articles/creating-a-free-website-status-page-using-uptime-robot!

1 Like

I think it is better to have a server to response with the data you need and then the API key would be stored in servers env variables so noone would be able to see it.

glitch.project.me → GET myhost.com/monitor{ host: glitch.project ... }

1 Like

That is a good idea, but the whole code is written in PHP, so it is a big task to convert it into JavaScript. Also, I can’t GET using the Uptime Robot API, there are only POST request in the API documentation. Can you help?

@khalby786 Might not wanna include your API key in the project so everybody can see it.
-Happy Glitching tech_dude1

1 Like

No, actually, monitor-specific API key was meant to be displayed in the browser (in the client), so that no can use the Main API key to misuse it.

The php-express package overrides env with its own values, which is why the env variables aren’t being passed to php. The package has pull requests to partially fix this, but they haven’t been merged, and the project is stagnant.

I think you’d be better off with a simple PHP server, similar to @J-Tech-Foundation did in I can't php page access

Summary: remove package.json and the node files, add a file glitch.json (I made a minor improvement)

{
  "install": "echo 'No install needed'",
  "start": "php -S 0.0.0.0:${PORT} -t ."
}

Working example,
Project: https://glitch.com/~php-serve
Live: https://php-serve.glitch.me/

1 Like

Thanks a lot, @mishavee! That worked :smile:!

Oops it also serves the file .env, I’ll update with a fix soon!

What do you mean???

The problem is if someone types in the url https://php-serve.glitch.me/.env it would let them download the env file!

The fix is, to start a router script instead of serving all files. I’ve put a basic router script in, but it really needs a better one, I’ll update with it soon.

Okay, a simpler fix than a router:

1 . Move the content into a folder /public

2 . Alter the glitch.json to be

{
  "install": "echo 'No install needed'",
  "start": "php -S 0.0.0.0:${PORT} -t public"
}

A router would be needed for more complex rules, such as a custom 404 page.

i can improve your current script

@mishavee, is that all? It worked well, and when I type https://discord-status-page.glitch.me/.env, it said 'could not find .env’ so that must be it, I guess :blush:

yes, it can work like that, if you move it to a different non- root directory, but otherwise, it is extremely difficult to tell php not to serve the .env file

{
  "install": "rm -rf public; cp ~/ ~/public; rm -rf **/.env",
  "start": "php -S 0.0.0.0:3000 -t public || echo 'ERR' && > er.txt"
}

anytime you want to remove something from the public directory for posting, just add

rm -rf **/FILE_NAME

that logs all errors, and sets a public server

the er.txt is the error catcher, anytime there is an error, it prints ERR to console, then logs the error to the error log.

1 Like

Thanks a lot! I’ll try this as well!

Why did you put that " Status page by Khaleel Gibran." since you didnt made that https://stevencotterill.com/articles/creating-a-free-website-status-page-using-uptime-robot

1 Like

Okay, you caught me, I’ll totally agree, but I was insisting on it being converted to JavaScript, since the PHP looked tedious. Later, I had to improve the PHP variables, because even that guy was using the older version of the Uptime Robot API! And since that was an act of plagiarism (all apologies here) from my side, I’ll remove that. Sorry @GhostSlayer, and I promise that I won’t copy projects any more! But in my defense, it was open-source, and I hadn’t completely plagiarized the whole project! Sorry for that once again.

1 Like

Also, I think I should tell you this! This was not meant to be the project to be displayed here. I had read this article mentioned above several months back and I had been intending to create another project that would remix this project and pass .env values by sending a POST request to the Glitch API, but since I was deficient in the knowledge needed to create that (especially the Glitch API), I had satisfied myself by tweaking the original status page, and waiting for something like the Glitch API to be released. And when a documented version of the Glitch API was released recently, I’ve been trying how I could pass .env values. Also, I wanted to send emails for updates in the status, but again, I didn’t know how to create it at that time. And yes folks, the status page was made when I followed that article @GhostSlayer mentioned. And yes, I should have mentioned that (as well as this) earlier. Sorry for any trouble caused due to this. If you insist, I can pull back this project and revise it, until it’s no longer plagiarized in the future.

Sorry for the trouble caused everyone,
Khaleel Gibran :slight_smile:

1 Like

Hey @khalby786,

All you need to do is include the license, and attribute the original author, on your modified copy.

1 Like