Jump to content

ohno

Members
  • Posts

    103
  • Joined

  • Last visited

  • Days Won

    1

ohno last won the day on March 28 2020

ohno had the most liked content!

ohno's Achievements

Regular Member

Regular Member (3/5)

2

Reputation

  1. Sorted it, I think! RewriteEngine On RewriteCond %{REQUEST_URI} !^/admin/ RewriteCond %{DOCUMENT_ROOT}/site-error.php -f RewriteCond %{DOCUMENT_ROOT}/admin/maintenance.enable -f RewriteCond %{SCRIPT_FILENAME} !site-error.php RewriteRule .*$ /site-error.php [R=503,L] ErrorDocument 503 /site-error.php
  2. OK, so I made a test script that creates a file and deletes it for the above htaccess code :- RewriteEngine On RewriteCond %{DOCUMENT_ROOT}/site-error.php -f RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f RewriteCond %{SCRIPT_FILENAME} !site-error.php RewriteRule ^.*$ /site-error.php [R=503,L] ErrorDocument 503 /site-error.php The script that makes/deletes the file works fine, what I need to work out now is how to NOT include my admin directory in the above code, otherwise I can't re-enable the site as the whole site shows the error page! ie, I need to be able to still access /admin and all sub directories in it.
  3. I've sorted this now so if there is an SQL error a nice error page is displayed informing the user the site is experiencing a technical issue and will be online again soon. This got me thinking, is there an easy way to display a site maintenance page? So if a DB entry is set to true all requests get redirected to one page? I found this :-https://rimuhosting.com/knowledgebase/creating-a-maintenance-page-for-your-site But I'm not sure how to make a PHP script create or delete the maintenance.enable file?? Or is there a better way to achieve this? Thanks.
  4. Hmmm, the settings are deffo correct so I guess there is more to look into as I didn't get a 500 error. Good point on the other message.
  5. Ok, I got a white screen which I guess was expected? If I comment out this line : - mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); I get this error : - Failed to connect to MySQL: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known Which seems more helpful? (ie, if we have another SQL server error at least we know what the issue is without checking error logging??).
  6. OK, that's done. Would that now avoid the issue that the SQL server problem caused?
  7. Thanks, currently PHP is set to display errors (E_ALL & ~E_NOTICE), are you saying that should be disabled? I'm not a coder (!) but a pro coder did write the code above.
  8. Our hosts had an SQL server error which required the service to be restarted. However, while the site was down the error message gave the DB name, login & password! Fatal error: Uncaught mysqli_sql_exception: Connection refused in /home/domain/public_html/include/database.php:9 Stack trace: #0 /home/domain/public_html/include/database.php(9): mysqli->__construct('127.0.0.1', 'domain_DB, 'PASSWORD!!!', 'DB_USER_NAME!!!') #1 /home/domain/public_html/include/app_top.php(12): DbManager->__construct() #2 /home/domain/public_html/index.php(4): require_once('/home/domain/...') #3 {main} thrown in /home/domain/public_html/include/database.php on line 9 database.php :- function __construct() { mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $this->db = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); if ($this->db->connect_errno) { die("Failed to connect to MySQL: (" . $this->db->connect_errno . ") " . $this->db->connect_error); } Line 9 is $this->db = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); Looking at this guide :- https://www.w3schools.com/php/func_mysqli_error.asp Should the code look like this?? function __construct() { mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $this->db = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); if ($this->db->connect_errno) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit(); } Thanks
  9. I'll take another look, none of the examples I seemed to find showed how this could be done though. Thanks
  10. This works but doesn't add any hours outside of the whole days :- $elapsed = $d1->diff(new DateTime())->days * 24 * 60; eg, if the elapsed time is 7 days two hours it gives 10080 minutes instead of 10200.
  11. On a similar note, can the date string be converted to minutes rather than days? (in PHP that is). I did try $elapsed = $d1->diff(new DateTime())->i ;
  12. Hi, I have this code :- $datestarted = $row['datestarted']; $datestart=date("l d/m/Y @ H:i:s",strtotime($datestarted)); Which is been echo'd like this :- echo ' <tr align="center"'.$rowbackground.'> <td>'.$datestart.'</td> <td align="center"> '; So for example I get this output :-Sunday 18/04/2021 @ 10:45:26 The data in the DB for the above is stored like this :-2021-04-18 10:45:26 What I'd like to do is also echo how many days ago this date was, all of the examples I've tried don't seem to work though?
  13. To add, I tried the latest version of the script : - https://github.com/tuupola/lazyload#changelog & tried modifying this code : - let images = document.querySelectorAll(".example"); lazyload(images); To the span name but still nothing, the rendered HTML of the image is like this :- <span class="thumb" style="background-image: url(https://www.example.com/images/thumbnails/example.jpg);"></span> I wonder if the lack of height & width maybe causing it? (this info is in the CSS file but I'll try adding it inline now)
  14. Hi, I've implemented lazy loading on my website using this guide : - https://web.dev/codelab-use-lazysizes-to-lazyload-images/ However I can't get the last bit of code to work! Basically I have images that are in a span tag loaded as a background image, I have this is the CSS : - .blocks1 .block a span.thumb { width: 120px; height: 90px; background-repeat: no-repeat; background-position: center; background-size: contain; margin: 0 auto } The page uses this tpl file for the images : - {section name=c loop=$cats->mCats} <div class="block"><a class="clearfix" href="{$smarty.const.SITE_ROOT}/{$cats->mCats[c].menulinktext}/"><span class="thumb" style="background-image: url({$smarty.const.SITE_ROOT}{$smarty.const.IMG_DIR}/thumbnails/{$cats->mCats[c].img_category});"></span><span class="info">{$cats->mCats[c].name|escape:'htmlall'|widont}</span></a></div> {/section} I thought this script may have worked : - https://appelsiini.net/2013/lazyload-190/ But I couldn't get that to work either. Any idea's whether this can be done & if so how?! Many thanks for any help on this one
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.