Website URL
https://www.gr8brik.rf.gd/
Error Message
This site/page has used all available resources allowed for a free hosting account.
Refresh the page once the amount of resources has reduced.
We would recommend upgrading your hosting account at Our Premium Hosting , premium hosting accounts have much higher dedicated resources.
Other Information
Does this mean my site will be down until I pay money, or what?
Will my website shut down till I pay up? When will this stop?
Edit: Lol no It’s back. I’ll disable AJAX for a moment.
Oxy
September 2, 2024, 6:43pm
4
Your website will appear when the number drops
nothing to do with payment
The server simply protects itself from over-hungry websites
and it’s not fair that your website consumes a lot of resources, but it’s fair that other users also get an equal share of the cake (CPU/RAM, etc.)
you need to study the code and see how you can optimize it
5 Likes
This is the code that is causing the error:
$bbcode = array("[b]", "[/b]", "[i]", "[/i]", "[s]", "[/s]", "[u]", "[/u]");
$html = array("<strong>", "</strong>", "<em>", "</em>", "<s>", "</s>", "<u>", "</u>");
$phrase = $c_comment;
$new_comment = str_replace($bbcode, $html, $phrase);
while (strpos($c_comment, '[url]') !== false) {
$start = strpos($c_comment, '[url]') + 5;
$end = strpos($c_comment, '[/url]', $start);
$url = substr($c_comment, $start, $end - $start);
$post = substr_replace($c_comment, "<a href='$url'>$url</a>", $start - 5, $end - $start + 6);
}
Oxy
September 2, 2024, 6:48pm
6
Copilot AI
Optimizing your PHP code can help reduce the load on Apache processes. Here are a few suggestions to improve your code’s performance:
Use a single str_replace
call : Instead of calling str_replace
multiple times, you can use it once to replace all BBCode tags with their HTML equivalents.
Optimize the URL replacement loop : The current loop can be optimized by using regular expressions to replace all [url]
tags in one go.
Here’s an optimized version of your code:
PHP
$bbcode = array("[b]", "[/b]", "[i]", "[/i]", "[s]", "[/s]", "[u]", "[/u]");
$html = array("<strong>", "</strong>", "<em>", "</em>", "<s>", "</s>", "<u>", "</u>");
$new_comment = str_replace($bbcode, $html, $c_comment);
// Use regular expression to replace [url] tags
$new_comment = preg_replace_callback('/\url\\[\/url\]/', function($matches) {
$url = $matches[1];
return "<a href='$url'>$url</a>";
}, $new_comment);
3 Likes
Mostly this part:
while (strpos($c_comment, '[url]') !== false) {
$start = strpos($c_comment, '[url]') + 5;
$end = strpos($c_comment, '[/url]', $start);
$url = substr($c_comment, $start, $end - $start);
$post = substr_replace($c_comment, "<a href='$url'>$url</a>", $start - 5, $end - $start + 6);
}
Edit: solved by @Oxy
Oxy
September 2, 2024, 6:52pm
8
Take AI text with a grain of salt - maybe it works, maybe not, but it can be a guide in many cases.
Good luck with the website
4 Likes
Thanks. I’m expanding my PHP knowledge. I’ll look at some more docs around the web and see if I can get something a bit better for the BBcode.
3 Likes
system
Closed
September 9, 2024, 6:54pm
10
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.