Kevo89 Posted June 17, 2012 Share Posted June 17, 2012 Im working on a code $params['admins'] = array('Kevo' => 'Password); and i want to show a list of admin commands in a echo in a table when the user logs in as a admin, and non admins (guest) do not see the list. Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/ Share on other sites More sharing options...
PeoMachine Posted June 17, 2012 Share Posted June 17, 2012 How do you know who is Admin and who doesnt ? Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354643 Share on other sites More sharing options...
Kevo89 Posted June 17, 2012 Author Share Posted June 17, 2012 I set the users for admin like so... $params['admins'] = array('Kevo' => 'Yes', 'boby' => 'bobypw'); etc.. Everyone esle is a guest... And the admins has to put in their passwords to become admins. Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354644 Share on other sites More sharing options...
cyberRobot Posted June 17, 2012 Share Posted June 17, 2012 Basically, you would wrap the admin option in an if statement: if(adminIsLoggedIn) { display admin options } display options for everyone outside of the if Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354647 Share on other sites More sharing options...
Kevo89 Posted June 17, 2012 Author Share Posted June 17, 2012 this is what i have a basic <?php if('admins') { echo "display admin options"; } ?> its showing the echo statement all the time... what am i missing? Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354651 Share on other sites More sharing options...
Pikachu2000 Posted June 17, 2012 Share Posted June 17, 2012 if('admins') will always evaluate as TRUE. You probably want to look at in_array. Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354654 Share on other sites More sharing options...
Kevo89 Posted June 17, 2012 Author Share Posted June 17, 2012 humm... doesnt seem to work... :-\ Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354658 Share on other sites More sharing options...
Pikachu2000 Posted June 17, 2012 Share Posted June 17, 2012 Details. You've omitted them. Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354669 Share on other sites More sharing options...
Kevo89 Posted June 17, 2012 Author Share Posted June 17, 2012 I can load whole code if you want to so you will have better understanding... Ima do it any ways.. <?php require_once dirname(__FILE__)."/src/phpfreechat.class.php"; $params = array(); $params["title"] = "Web Chat"; $params["nick"] = "guest".rand(1,1000); // setup the intitial nickname $params['firstisadmin'] = false; //$params["isadmin"] = false; // makes everybody admin: do not use it on production servers $params['admins'] = array('Kevo' => 'Test', 'boby' => 'bobypw'); $params["theme"] = "zilveer"; $params["serverid"] = md5(__FILE__); // calculate a unique id for this chat $params["debug"] = false; $params["channels"] = array("HTML"); $params["frozen_channels"] = array("HTML","room1","room2","HTML5", "PHP", "Java", "CSS", "Flash"); $chat = new phpFreeChat( $params ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>phpFreeChat- Sources Index</title> <link rel="stylesheet" title="classic" type="text/css" href="style/generic.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/header.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/footer.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/menu.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/content.css" /> <?php $chat->printJavascript(); ?> <?php $chat->printStyle(); ?> <style type="text/css"> body { background-color: #333; } </style> </head> <body> <div class="header"> Web Information Chat <br /><font color="#FFCC33" size="2">// Bare with me, I am still woking on the site, please enjoy and read rules //</font> </div> <div class="menu"> <ul> <li class="sub title">General</li> <li> <ul class="sub"> <li class="item"> <a href="#">Rules</a> <font color="#FFCC33" size="2">//Coming Soon//</font> </li> <!-- <li class="item"> <a href="admin/">Administration</a> </li> --> </ul> </li> <li class="sub title">Rooms</li> <li><a href="#" onclick="pfc.sendRequest('/join HTML');">HTML</a></li> <li><a href="#" onclick="pfc.sendRequest('/join HTML5');">HTML5</a></li> <li><a href="#" onclick="pfc.sendRequest('/join PHP');">PHP</a></li> <li><a href="#" onclick="pfc.sendRequest('/join Java');">Java</a></li> <li><a href="#" onclick="pfc.sendRequest('/join CSS');">CSS</a></li> <li><a href="#" onclick="pfc.sendRequest('/join Flash');">Flash</a></li> </ul> </li> </ul> <p class="partner"> </p> </div> <div class="content"> <?php $chat->printChat(); ?> <?php if (isset($params["isadmin"]) && $params["isadmin"]) { ?> <p style="color:red;font-weight:bold;">Warning: because of "isadmin" parameter, everybody is admin. Please modify this script before using it on production servers !</p> <?php } ?> <?php if (isset($params['admins'])) { ?> <p style="color:red;font-weight:bold;">Testing</p> <?php } ?> </div> <div class="footer"> <span class="partners">Web Information Chat</span> </div> </body></html> Ok.. so what i have at the top are paramaters... $params['admins'] = array('Kevo' => 'Test', 'boby' => 'bobypw'); this is for when the admin comes into chat and he can change is status form guest/member to admin. Now down below i have <?php if (isset($params['admins'])) { ?> <p style="color:red;font-weight:bold;">Testing</p><?php } ?> , this for adding a list of commands for admins to see when they change their status to admins, the others cannot view the command list... this what i am trying to do. I hope this make sense and thanks for all the help. I have also tried using echo as well but was showing all the time... maybe i might have something wrong. Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354672 Share on other sites More sharing options...
Pikachu2000 Posted June 17, 2012 Share Posted June 17, 2012 The documentation for that package isn't very good. Have you tried uncommenting this line and see if that changes anything? //$params["isadmin"] = false; // makes everybody admin: do not use it on production servers Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354675 Share on other sites More sharing options...
Kevo89 Posted June 17, 2012 Author Share Posted June 17, 2012 Yes i have... like it said it puts everyone as admin and i dont want that.. MODS... sorry for posting in the wrong spot. Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1354678 Share on other sites More sharing options...
Kevo89 Posted June 24, 2012 Author Share Posted June 24, 2012 Solved.. I got it... Quote Link to comment https://forums.phpfreaks.com/topic/264339-need-help/#findComment-1356645 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.