Conditions | 2 |
Paths | 2 |
Total Lines | 69 |
Code Lines | 61 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
40 | public static function show($e_code, $pages = 1) |
||
41 | { |
||
42 | global $xoopsConfig; |
||
43 | |||
44 | $errmsg = [ |
||
45 | '0001' => 'Could not connect to the forums database.', |
||
46 | '0002' => 'The forum you selected does not exist. Please go back and try again.', |
||
47 | '0003' => 'Incorrect Password.', |
||
48 | '0004' => 'Could not query the topics database.', |
||
49 | '0005' => 'Error getting messages from the database.', |
||
50 | '0006' => 'Please enter the Nickname and the Password.', |
||
51 | '0007' => 'You are not the Moderator of this forum therefore you can\'t perform this function.', |
||
52 | '0008' => 'You did not enter the correct password, please go back and try again.', |
||
53 | '0009' => 'Could not remove posts from the database.', |
||
54 | '0010' => 'Could not move selected topic to selected forum. Please go back and try again.', |
||
55 | '0011' => 'Could not lock the selected topic. Please go back and try again.', |
||
56 | '0012' => 'Could not unlock the selected topic. Please go back and try again.', |
||
57 | '0013' => 'Could not query the database.', // <br>Error: ' . mysql_error() . '', |
||
58 | '0014' => 'No such user or post in the database.', |
||
59 | '0015' => 'Search Engine was unable to query the forums database.', |
||
60 | '0016' => 'That user does not exist. Please go back and search again.', |
||
61 | '0017' => 'You must type a subject to post. You can\'t post an empty subject. Go back and enter the subject', |
||
62 | '0018' => 'You must select message icon to post. Go back and select message icon.', |
||
63 | '0019' => 'You must type a message to post. You can\'t post an empty message. Go back and enter a message.', |
||
64 | '0020' => 'Could not enter data into the database. Please go back and try again.', |
||
65 | '0021' => 'Can\'t delete the selected message.', |
||
66 | '0022' => 'An error occurred while querying the database.', |
||
67 | '0023' => 'Selected message was not found in the forum database.', |
||
68 | '0024' => 'You can\'t reply to that message. It wasn\'t sent to you.', |
||
69 | '0025' => 'You can\'t post a reply to this topic, it has been locked. Contact the administrator if you have any question.', |
||
70 | '0026' => 'The forum or topic you are attempting to post to does not exist. Please try again.', |
||
71 | '0027' => 'You must enter your username and password. Go back and do so.', |
||
72 | '0028' => 'You have entered an incorrect password. Go back and try again.', |
||
73 | '0029' => 'Couldn\'t update post count.', |
||
74 | '0030' => 'The forum you are attempting to post to does not exist. Please try again.', |
||
75 | '0031' => 'Unknown Error', |
||
76 | '0035' => 'You can\'t edit a post that\'s not yours.', |
||
77 | '0036' => 'You do not have permission to edit this post.', |
||
78 | '0037' => 'You did not supply the correct password or do not have permission to edit this post. Please go back and try again.', |
||
79 | '1001' => 'Please enter value for Title.', |
||
80 | '1002' => 'Please enter value for Phone.', |
||
81 | '1003' => 'Please enter value for Summary.', |
||
82 | '1004' => 'Please enter value for Address.', |
||
83 | '1005' => 'Please enter value for City.', |
||
84 | '1006' => 'Please enter value for State/Province.', |
||
85 | '1007' => 'Please enter value for Zipcode.', |
||
86 | '1008' => 'Please enter value for Description.', |
||
87 | '1009' => 'Vote for the selected resource only once.<br>All votes are logged and reviewed.', |
||
88 | '1010' => 'You cannot vote on the resource you submitted.<br>All votes are logged and reviewed.', |
||
89 | '1011' => 'No rating selected - no vote tallied.', |
||
90 | '1013' => 'Please enter a search query.', |
||
91 | '1016' => 'Please enter value for URL.', |
||
92 | '1017' => 'Please enter value for Home Page.', |
||
93 | '9999' => 'OOPS! Unknown Error', |
||
94 | ]; |
||
95 | |||
96 | $errorno = array_keys($errmsg); |
||
97 | if (!in_array($e_code, $errorno)) { |
||
98 | $e_code = '9999'; |
||
99 | } |
||
100 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
101 | echo '<div><strong>' . $xoopsConfig['sitename'] . ' Error</strong><br><br>'; |
||
102 | |||
103 | echo "Error Code: $e_code<br><br><br>"; |
||
104 | echo "<strong>ERROR:</strong> $errmsg[$e_code]<br><br><br>"; |
||
105 | echo '[ <a href=\'javascript:history.go(-' . $pages . ')\'>Go Back</a> ]</div>'; |
||
106 | |||
107 | include_once XOOPS_ROOT_PATH . '/footer.php'; |
||
108 | exit(); |
||
|
|||
109 | } |
||
112 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.