Xarcell Posted October 19, 2012 Share Posted October 19, 2012 I'm looking for a way to create custom error pages, but I'm not seeing a solution. Anything out there that works and is current(WHMCS 5.1)? 0 Quote Link to comment Share on other sites More sharing options...
Xarcell Posted October 19, 2012 Author Share Posted October 19, 2012 Nevermind, after some research, and updating some code in some scripts by various members, I managed to make custom error pages. I'll share with you what I have so that others by benefit from it. This can be done in 5 easy steps, with no coding knowledge required. 1.| Create a "error.php" file with this as it's contents: <?php define("CLIENTAREA",true); //define("FORCESSL",true); # Uncomment to force the page to use https:// require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); $pagetitle = $_LANG['clientareatitle']; $breadcrumbnav = '<a href="index.php">'.$_LANG['globalsystemname'].'</a>'; $breadcrumbnav .= ' > <a href="error.php">Whoops!</a>'; initialiseClientArea($pagetitle,'',$breadcrumbnav); # To assign variables to the template system use the following syntax. # These can then be referenced using {$variablename} in the template. $smartyvalues["variablename"] = $value; # Check login status if ($_SESSION['uid']) { # User is logged in - put any code you like here # Here's an example to get the currently logged in clients first name $result = mysql_query("SELECT firstname FROM tblclients WHERE id=".(int)$_SESSION['uid']); $data = mysql_fetch_array($result); $clientname = $data[0]; $smartyvalues["clientname"] = $clientname; } else { # User is not logged in } # Define the template filename to be used without the .tpl extension $templatefile = "error"; $referer = $HTTP_REFERER; $smarty->assign("refer", $referer); switch($e) { default: $e="404"; break; case '400': $e="400"; break; case '401': $e="401"; break; case '403': $e="403"; break; case '404': $e="404"; break; case '500': $e="500"; break; case '503': $e="503"; break; } $smarty->assign("e", "$e"); outputClientArea($templatefile); ?> 2.| Upload the "error.php" file to your WHMCS "root" directory. 3.| Create a "error.tpl" file with this as it's contents: <div class="page-header"> <div class="styled_title"><h1>Whoops! <small>Sometimes these things happen...</small></h1></div> </div> {if $e==400} <h2>Error 400</h2><p>The server made a bad request. Please try again later. Thank you.</p> {/if} {if $e==401} <h2>Error 401</h2><p>You need authorization to proceed beyond this point. If you forgot your password or username, you'll need to notify my <a href=/contact.php>admin</a>. Thanks</p> {/if} {if $e==403} <h2>Error 403</h2><p>.Permission Denied.<br>I'd love to give you permission, but you see, my owner has requested this specific file is off limits to you. I can even show you the request.</p> {/if} {if $e==404} Referrer: {$refer} <h2>Error 404</h2><p>The file requested does not exist on this server. Perhaps you forgot the filename. Perhaps this was moved, and the <a href={$refer}>referring page</a> should be notified.If you were looking for the order page, that can be found <a href=/order.php>here</a>.</p> {/if} {if $e==500} <h2>Error 500</h2><p>Something has gone wrong with one of my scripts and I'm clueless as to what. Maybe my logs will contain a bit more information.</p> {/if} 4.| Upload the "error.tpl" file to your "template/YOUR-THEME-USED" directory. 5.| Add these lines to your .htaccess file(a hidden file in your WHMCS root): #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} ErrorDocument 400 /error.php?e=400 ErrorDocument 401 /error.php?e=401 ErrorDocument 403 /error.php?e=403 ErrorDocument 404 /error.php?e=404 ErrorDocument 500 /error.php?e=500 Done. Enjoy! 1 Quote Link to comment Share on other sites More sharing options...
wsa Posted October 19, 2012 Share Posted October 19, 2012 you can check out this two http://www.whmcs.com/appstore/13/Sparkys-ErrorPages.html or http://www.whmcs.com/appstore/423/WHMCS-Errors-Plus.html 0 Quote Link to comment Share on other sites More sharing options...
Montarbot Posted December 20, 2012 Share Posted December 20, 2012 Thank you very much 0 Quote Link to comment Share on other sites More sharing options...
Deeco Posted January 1, 2013 Share Posted January 1, 2013 Can we have a Screenshot? thanks! 0 Quote Link to comment Share on other sites More sharing options...
daferub Posted April 6, 2013 Share Posted April 6, 2013 Hello, Please, can you update the error.php according the new version of whmcs 5.2.3 http://docs.whmcs.com/Creating_Pages. This post was written on Oct 2012. Regards 0 Quote Link to comment Share on other sites More sharing options...
daferub Posted April 6, 2013 Share Posted April 6, 2013 Here the error.php updated for version 5.2 <?php define("CLIENTAREA",true); //define("FORCESSL",true); // Uncomment to force the page to use https:// require("init.php"); $ca = new WHMCS_ClientArea(); $ca->setPageTitle("Error"); $ca->addToBreadCrumb('index.php',$whmcs->get_lang('globalsystemname')); $ca->addToBreadCrumb('error.php','Error'); $ca->initPage(); //$ca->requireLogin(); // Uncomment this line to require a login to access this page # To assign variables to the template system use the following syntax. # These can then be referenced using {$variablename} in the template. $ca->assign('variablename', $value); # Check login status if ($ca->isLoggedIn()) { # User is logged in - put any code you like here # Here's an example to get the currently logged in clients first name $result = mysql_query("SELECT firstname FROM tblclients WHERE id=".$ca->getUserID()); $data = mysql_fetch_array($result); $clientname = $data[0]; $ca->assign('clientname', $clientname); } else { # User is not logged in } # Define the template filename to be used without the .tpl extension $ca->setTemplate('error'); $referer = $HTTP_REFERER; $smarty->assign("refer", $referer); switch($e) { default: $e="404"; break; case '400': $e="400"; break; case '401': $e="401"; break; case '403': $e="403"; break; case '404': $e="404"; break; case '500': $e="500"; break; case '503': $e="503"; break; } $ca->assign("e", "$e"); $ca->output(); ?> 0 Quote Link to comment Share on other sites More sharing options...
laffinboy Posted July 8, 2013 Share Posted July 8, 2013 Thank you. I'd been looking for a solution and this works perfectly. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.