NATS3 custom errors.php

From TMM Wiki
Jump to navigationJump to search
NATS 3
Skins & Templates Admin
Smarty Plugins
Skins
Editing Skins
Creating Skins
Switching Skins
Templates
nats_code
Affiliate Stats Template
Affiliate Support Template
Affiliate Login Template
custom errors.php
Template Array Variable
Detailed Stats
NATS Variables
Dialer Statistics
Affiliate Signup
Post URL Variables
Member Usernames & Passwords
Output An Affiliate's Last Paid Date
Custom Program and Campaign Selection Pages
CAPTCHA Removal
Username Recommendations
Password Retrieval
Post-Biller Templates
Geo-Target Join Options
Template Caching
Random Usernames and Passwords
Base Templates
Protecting Template Data
Mail Reseller Signup Template Variable Names
Smarty
Smarty print array
News Section Templating
Affiliate Signup Email
Getting The NATSCode
Checking for Usernames on All Sites
Adding Stats to Affiliate Pages
Affiliate Join Page Linkcodes

Applies to NATS 3.1.24.0 and greater.

NATS has normally displays errors in the form of a very simple error message. This error is for support personnel and does not contain much information for you as a program owner and administrator, but now you can use custom_errors.php to customize how NATS's error handling.

The following example shows an error in the standard format.

Figure 1.1 - The Original Error Message Format

custom_errors.php

Create a file in nats/includes/ called custom_errors.php. This file may contain anything you want to both display an error message to the surfer, affiliate, or admin and also to record this error. Before creating your own custom_errors.php script, please read this entire article, including the last section, Warnings and Recommendations. You have access to the following PHP variables in custom_errors.php:

  • $errstr - This variable contains the actual text of the error message.
  • $errfile - This variable contains the file from which the error was encountered.
  • $errline - This variable contains the line number of the file contained in $errfile.

Note: You can't use the error file and line number yourself. All Too Much Media product PHP files are encoded and cannot be debugged by end-users.

Figure 1.3 - Customized custom_errors.php Sample (SAMPLE ONLY - Password Censored)
Figure 1.4 - Customized custom_errors.php Output (SAMPLE ONLY)

This example is fairly simplistic -- it reports the standard error code text, logs this error message to a custom database and table, and finally provides the user with a link to manually report the error message to the program owner. Navigation links were also included at the bottom of the page to go back one page in history and return to the main program page.

Since this is a PHP script, you have access to all of the PHP "superglobal" variables and the full power of PHP. You can make your custom_errors.php script do pretty much anything you want it to do.


Warnings and Recommendations

This script will not always run; in some errors or server crashes, this script may not execute. If there is a critical PHP component that's failing, for example, NATS won't run long enough to process the error.

If you're reporting your errors to a MySQL database and NATS has a problem with the MySQL server, there is no way for custom_errors.php to report the error to the database.

WARNING: do not use the NATS database to log errors. If you're reporting your errors to a MySQL database, create separate database You'll note that in Figure 1.3, the database username, password, and host information is stored in plain text; if you use the NATS database login information or that of any other secure database, you risk exposing your login information to the public. If this script modifies the content of the NATS database table structure or data content, we will not be able fix your problems.

WARNING: do not display sensitive data.