Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: [MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)  (Read 4979 times)

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« on: November 28, 2006, 06:12:29 PM »

This mod is still in development stage*
applies to: sNews 1.5 RC1-3
version: 0.8

1. backup your .htaccess and snews.php files

2. create file called 404.htm and upload it to your sNews installation folder (the site root or in a folder where your sNews installation resides)

3. .htaccess file
- insert your domain name (and folder if needed)
Quote
# add this line somewhere at the top of .htaccess file
ErrorDocument 404 http://your-domain/404.htm
# if using subfolder then use the next line instead
ErrorDocument 404 http://your-domain/your-snews-folder/404.htm
4. snews.php - replace entire function or just paste changes to the code from BEGIN to END
Quote
// STARTUP
function snews_startup() {
   connect_to_db();
   if (get_id('category') == 'rss') {rss(); die;}
   update_articles();
   if (isset($_POST['Loginform']) == 'True') {
      if (clean($_POST['uname']) == s('username') && md5(clean($_POST['pass'])) == s('password')) {
         $_SESSION[db('website').'Logged_In'] = 'True'; $_SESSION['uname'] = s('username'); $_SESSION['Website'] = db('website');
      }
   }
/*NEW CODE BEGIN*/
   $categorySEF = get_id('category'); $articleSEF = get_id('article');
   $cat = retrieve('seftitle', 'categories', 'seftitle', $categorySEF);
   $art = retrieve('seftitle', 'articles', 'seftitle', $articleSEF);
   if ((!empty($categorySEF) && $cat == false && check_category($categorySEF) != true) || (!empty($articleSEF) && $art == false)) {
      echo '';
   }
/*NEW CODE END*/
}
snews_startup();
If you want to see this mod in action, feel free to rape my site :D
_____________
* This is one of my quick fixes - I still need to fix appropriate response headers, and some minor details...
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

iatbm

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 251
    • Public domain photos
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #1 on: November 28, 2006, 06:50:06 PM »

Yea it kind of works Mika but still the server put out 200 OK status and not 404 :(

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #2 on: November 28, 2006, 07:00:42 PM »

yep, I've already said that headers need fixing ;)
unless you come up with the fix, I'll deal with it when time permits me, okay?
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

iatbm

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 251
    • Public domain photos
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #3 on: November 28, 2006, 07:09:20 PM »

all right hehe ;) I missed that *

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #4 on: November 28, 2006, 07:30:56 PM »

GOD AL FECKING MIGHTY: http://www.ni5ni6.com/four-o-four.htm :lol:
Logged
"It's only dead fish that goes with the flow... "
Updated

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #5 on: November 29, 2006, 06:31:50 AM »

hehe...remember that?
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

bramsyuur

  • Hero Member
  • *****
  • Karma: 23
  • Posts: 873
    • http://snews.vietbee.net
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #6 on: November 29, 2006, 06:40:59 AM »

Thanks Mika for another contribution!  ;)
Try to adding this :
Quote
header("HTTP/1.1 404 Not Found");
before this line:
Quote
echo '';
I've revised my apache log's and I see the correct header "404 Error" line:
Quote
127.0.0.1 - - [29/Nov/2006:14:31:16 +0900] "GET /blablabla HTTP/1.1" 404 9672
In some cases, the header("HTTP/1.1 404 Not Found"); don't work as expected (because of type of php compilation in the server). In this case, use this alternative:
Quote
header("Status: 404 Not Found");
Thanks,
bram.
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Español

markuz

  • Newbie
  • *
  • Karma: 0
  • Posts: 22
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #7 on: December 02, 2006, 10:54:12 AM »

This is a good add-on and increases usability and decreases user's confusion in case of an error. That's why it definitely should be a core function. It is recommended, that the error pages should be always customized with all the needed information (see e.g. Jacob Nielsen), but I always want to remind people, that the user must feel, that they have the control over what they do, and one think to make that possible is consistency. By making a separate error page which doesn't follow the sites design confuses the user.

So my wish is to have an error page with a correct header within the site. By implementing that, the error page would also became editable through the admin settings, wouldn't it?
Logged

markuz

  • Newbie
  • *
  • Karma: 0
  • Posts: 22
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #8 on: December 02, 2006, 12:48:50 PM »

By the way, there is a slight problem with non-english sites. If you change the Home SEF from the settings to something else than 'home' you get error page when trying to access pages, which have that word in url. One solution is to add that Home SEF into the $l['cat_listSEF']-array afterwards, but it would be better, if there would be an automatic solution.
Logged

Vorsoron

  • Newbie
  • *
  • Karma: 0
  • Posts: 25
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #9 on: December 03, 2006, 12:27:47 PM »

I found another problem... When I click Next on Pagination, it recognizes as a 404 and redirects to the 404 page.
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD / ADDON] sNews 404 error page (sNews 1.5 RC1-3)
« Reply #10 on: December 03, 2006, 12:38:45 PM »

If you're using 1.5 stable, then you don't need this mod. However, if you do want to create custom 404, then use only htaccess part of the mod.
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version