TeddyKiller Posted April 21, 2010 Share Posted April 21, 2010 if I had a page called.. settings.php this had perhaps one setting for.. site display. I mean.. the setting to display site to all users, or display a site to admins only and the rest see an under construction page for example. How would I do it, handle it all etc? Quote Link to comment https://forums.phpfreaks.com/topic/199313-website-settings-how-do-i-handle-them/ Share on other sites More sharing options...
teamatomic Posted April 21, 2010 Share Posted April 21, 2010 sessions and access level. $access=$_SESSION['access_level']; if($acess>=2) {$page=index.php; if($access>=9)$page2=admin.php; }else {$page=under_construction.php;} or something like that depending on how your control is setup. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/199313-website-settings-how-do-i-handle-them/#findComment-1046081 Share on other sites More sharing options...
TeddyKiller Posted April 21, 2010 Author Share Posted April 21, 2010 sessions and access level. $access=$_SESSION['access_level']; if($acess>=2) {$page=index.php; if($access>=9)$page2=admin.php; }else {$page=under_construction.php;} or something like that depending on how your control is setup. HTH Teamatomic I was thinking along the lines of.. classes? include("settings.php"); class settings { public $status; public function sitestatus() { if($this->status == '1') { header("location: error.php?csok=24131"); } } } $settings = new settings(); $settings->status = $status; //gets this from settings.php $settings->sitestatus(); Then I thought.. what if I had to extend settings.. I could call private functons within the public function. Though depending on the return of them.. some may return values, some may redirect, some may return nothing. That wont be possible to handle in just a public function? Quote Link to comment https://forums.phpfreaks.com/topic/199313-website-settings-how-do-i-handle-them/#findComment-1046088 Share on other sites More sharing options...
ignace Posted April 21, 2010 Share Posted April 21, 2010 Do not use if ($accesLevel === 1) This is annoying as anyone joining your project needs to create a "map" to match numbers to roles/groups instead use if ($accessLevel === GROUP_ADMINISTRATOR) Everyone knows in a blink that the if-body contains code specific for administrators while if ($accessLevel === 5 || $accessLevel === 12) Just keeps you guessing as to whom this applies. Some gave the argument that they were alone on the project and knew what numbers represent which roles. Well, try to go over this code again 6 months after you wrote this. Still remember? Make your maintenance work as easy as possible not harder, you just increase the chances of breaking your code. In OOP terms there are many ways you can go, but your client most presumably wants to be able to add roles leaving you no option of hard-coding them. Zend_Acl gives you some great options in Access-Control. Quote Link to comment https://forums.phpfreaks.com/topic/199313-website-settings-how-do-i-handle-them/#findComment-1046112 Share on other sites More sharing options...
Philip Posted April 21, 2010 Share Posted April 21, 2010 If you have access to it, you could also use .htaccess - I find that a lot easier to deal with, regarding redirection etc. Quote Link to comment https://forums.phpfreaks.com/topic/199313-website-settings-how-do-i-handle-them/#findComment-1046114 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.