PHP - Php Navigation - Changing Background Colour When Active
I have got a code working to generate a menu from a mysql table, but I wan't to know if it is possible to have the background colour change to a third option when active.
I have 1 background colour for 'off', one for mouseover, but can't figure out how to tell it what they current page is so that it will use a different css class value, as the page obviously reloads after the link is clicked. Is it possible (hope my explanation makes some sence!) My code: At the moment mainNav a: and mainNav a:hover work ok but what I want is a mainNav a:active to stay on after the page has loaded Code: [Select] <?php //function to nest the menu tree function nest_child(&$nodes, $current) { if (!isset($nodes) || count($nodes) < 1) { return; } foreach ($nodes as $id => $item) { if ($current['parentdocid'] == $id) { if (!isset($item['children'])) { $item['children'] = array(); } array_push($item['children'], $current); $nodes[$id] = $item; } else { nest_child($item['children'], $current); } } } //functions to display the tree and expand as appropriate function menu_display($nodes, $display_id) { if (!isset($display_id) || ($display_id == '')) { $display_id = 1; } $result = node_display( array( 'doc_id' => 1, 'children' => $nodes ), $display_id ); return $result[1]; } function node_display($node, $display_id) { global $ROOT; $found = false; $text = ''; if (isset($node[children])) { foreach ($node[children] as $id => $child) { $text .= "<li class='mainNav'><a href='$ROOT/index.php?doc_id=$child[doc_id]'>$child[doc_name]</a>"; $result = node_display($child, $display_id); if ($result[0]) { $found = true; $text .= "<ol>$result[1]</ol>"; } if ($child[doc_id] == $display_id) { $found = true; if (isset($child[children])) { $text .= "<ol>"; foreach ($child[children] as $id => $grandchild) { $text .= "<li class='mainNav'><a href='$ROOT/index.php?doc_id=$grandchild[doc_id]'>$grandchild[doc_name]</a>"; } $text .= "</ol>"; } } $text .= "</li>"; } } if ((!$found) && ($display_id != 1)) { $text = ''; } return array($found, $text); } ?> <ul class="menu"> <?php //retrieve all the menu elements $result = mysql_query('SELECT * FROM docs ORDER BY doc_order ASC'); $menu = array(); while ($row = mysql_fetch_assoc($result)) { $menu[$row['doc_id']] = $row; } //nest the elements foreach ($menu as $id => $item) { if ($item['parentdocid'] != 1) { nest_child($menu, $item); unset($menu[$id]); } } //display the tree print menu_display($menu, $doc_id); ?> </ul> Similar Tutorialshello navigation - how can i get the id of an active tab i have a top nav which is pulling its tabs from a database how can i get the id of the active tab then pass it in a global to side navigation this is the top nav code Code: [Select] <?PHP require_once("../includes/initialize.php"); global $topNavs; global $pageName; ?> <div id="navWrapper"> <?PHP $topNav = navL1::find_all(); ?> <div id="ddtabs3" class="solidblockmenu"> <ul> <?PHP foreach($topNav as $topNavs): ?> <li><a <?PHP echo ($pageName == $topNavs->title ? 'class="selected"' : '')?> href="<?PHP echo $topNavs->title; ?>.php" id="<?PHP echo $topNavs->title; ?>"><?PHP echo $topNavs->title; echo $topNavs->id;?></a></li> <?PHP endforeach; ?> </ul> </div><!-- #ddtabs3--> </div><!-- #navWrapper--> this prints the id of 5 which is the last tab in my database. if i have tab 1 active how can i get my loop to get that id ? thanks rick This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=344421.0 Code: [Select] <div id="nav"> <ul> <li class="item"><a href="/">Home</a>/</li> <li class="item"><a href="/one">one</a></li> <li class="item"><a href="/two>two</a></li> <li class="item"><a href="/three">three</a></li> </ul> <div> i want to add class='active' to the a tags . when the menu is the current page. namely.when i on the home page. the a label is Code: [Select] <li class="item"><a href="/" class="active">Home</a>/</li> .but the others a label are not have class="active". when i on the one page. it is is Code: [Select] <li class="item"><a href="one" class="active">one</a>/</li>.the others a label are not have class="active". Hi. I am looking for a way to have a button that toggles the background colour of my website. So for instance, I will have one button called 'switch to light', when its clicked it switches the colour of the background to a light colour, and another button replaces this that says 'switch to dark', and so on. I have turned to PHP because it appears to be the only way I would be able to have the change saved throughout the site, when pages are refreshed. However, I am a complete newbie, so have no idea what to do! Anyone that can help is a life saver! Thanks Hi, I have looked everywhere for a way to do this and would be grateful for a pointer in the right direction. I want to change the background color of the div with the id of "loggedin", depending on the status. The status currently echos text depending on the value. Code: [Select] <div class="grid_12" id="loggedin"> <div> <ul id="loggedin"> <li><?php global $current_user; get_currentuserinfo(); echo 'Status : ' . $current_user->status . "\n";?></li> <li> <?php if ($current_user->status=="RED") echo "Red info"; ?> <?php if ($current_user->status=="GREEN") echo "Green info"; ?> <?php if ($current_user->status=="BLUE") echo "Blue info"; ?> <?php if ($current_user->status=="YELLOW") echo "Yellow info"; ?> </li> </div> </div> Thanks This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317523.0 I was trying to show different hex codes as background in a loop for each section of a list. Here's what I done Code: [Select] $rgb; $rgb["c1"] = "ff4c54"; $rgb["c2"] = "ff764c"; $rgb["c3"] = "ffde4c"; $rgb["c3"] = "c7f25f"; $rgb["c4"] = "33c9f7"; $i=0; $pargs = array( 'numberposts' => 10,'orderby'=> 'comment_count', ); $myposts = get_posts( $pargs );$max_count=0; <ul> foreach( $myposts as $post ) : setup_postdata($post); <li style="width:300px;background-color:#<?php foreach($rgb as $color => $hex) { echo $hex[i]; $i++; } ?>"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> - </li> <?php endforeach; ?> </ul> Ending up with just the white background.. and no change in the background colors. Kindly help Hi, I am am looking to develop further the code below. This code allows me to display a left navigation bar with Main Links and then if you click a Main link, that link is listed first in the list and its' submenu appears below. For the majority of links in the navigation bar this is fine. But for about 2 of the Main links this basic navigation is not suitable. I need the navigation for 2 of the links to offer more depth. So, for example, if you click Accessories in: Shoes Trousers Shirts Accessories Looks like this if Accessories is clicked: Accessories Belts Cuff Links Wallets Shoes Trousers Shirts Looks like this if belts is clicked (Main link name changed and submenu changed): Accessories - Belts Brown leather Black Leather Multicolour Designs All casual All formal Shoes Trousers Shirts Looks like this is Brown Leather is clicked: Brown Leather Belts Armani Brown Leather Belt 32" Armani Brown Leather Belt 34" Hugo Boss Brown Leather Belt 32" Hugo Boss Brown Leather Belt 34" Shoes Trousers Shirts Currently the code does not allow for this depth in the navigation bar. Any ideas how it could be done? Do I need additional tables for each subcategory. How do I ensure the category clicked does not appear in the rest of the navigation bar, as in the code I have at the moment? Currently the code is: $res = mysql_query("SELECT * FROM categories"); while($row = mysql_fetch_array($res)) { $cats[$row['categoryid']] = $row['categoryname']; } if(isset($_GET['category'])) { $selcat = $_GET['category']; } if(isset($_GET['product'])) { $prod_info = mysql_fetch_array(mysql_query("SELECT * FROM products WHERE productid = ".$_GET['product'])); //Prod_Info now gets stored for use in the main display. $selcat = $prod_info['categoryid']; } if(isset($selcat)) { echo "<a href='categorylist.php?category=".$selcat."'>".$cats[$selcat]."</a>"; unset($cats[$selcat]); //Gets rid of it for later. $res = mysql_query("SELECT productid,name FROM products WHERE categoryid = ".$selcat); while($row = mysql_fetch_array($res)) { echo "<a href='product.php?product=".$row['productid']."'>".$row['name']."</a>"; } } foreach($cats AS $key => $cat) { echo "<a href='categoryview.php?category=".$key."'>".$cat."</a>"; } Thank you for looking at this post, Matt. I'm wondering how I can find the x, y coordinates on an image in PHP where a specific colour lies. If there was a #000000 coloured pixel located on 127, 205, how could I use PHP to find the 127, 205 by just telling it #000000? Hi I have a table that populated by a recordset, and wondered whether is was possible to make a row background colour = red where a particular cell = some text? I have been searching around and not managed to find anything of use. Any help would be appreciated. I have a database with Users as a table. It has the normal stuff, id, username, password, and I have anther in it called lastactive. It is DATETIME, and I am wondering how I would make a sql query select the users in the database 'users' and see who has been active in the past 15 mins. What I am asking is how I could do this, and would it be better to use a different structure other then DATETIME. Hello guys, before I start I'm a relativity new user of PHP so this really could be something extremely simple, I just can't seem to find it, Basically on my website i have php login script, when you're logged on every page you visit checks a file called auth.php, This will tell create a session called, "$SESSION" Inventive i know... That will tell the browser if the user is logged in or not, so it can decide whether or not to create a Login button, or a Log out button, Here's the code i have so far. if ( $SESSION == '' ) { echo "<a href='logout.php" ."Log out"; } else { echo "<a href='login-form.php" ."Log in"; } Now, I believe i'm on the right lines? But i'm not fully sure how to basically in English say, If that session is working or exists, Then do this, if not, do this. I mention again, I'm very new to PHP so any help would be very appreciated! I added <?php $_menu = ''?> <?php foreach ($this->getStoreCategories() as $_category): ?> <?php $_menu .= $this->drawItem($_category) ?> <?php endforeach ?> <?php if ($_menu): ?> <div class="nav-container"> <ul id="nav"> <li class="level0 first nav-home"><a href="<?php echo $this->getUrl() ?>"><span><?php echo $this->__('Home') ?></span></a></li> <?php echo $_menu; ?> <li class="level0 nav-1 parent"><a href="<?php echo $this->getUrl('contacts')?>"><span><?php echo $this->__('Contact') ?></span></a></li> <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu')->toHtml() ?> </ul> </div> <?php endif; ?> to top.phtml and it works as expected, I now have CMS links in my nav but how can I make them have active state like the category links do?? here is the site: http://pro-tools-training.com/new-magento/index.php/video-1.html Sorry if i posted this in the wrong place but i dident see anthing about Active Directory or Security Questions
But has anyone used Active Directory as their User Database? Has anyone even tryed braking Active Directory with injection attacks?
Notes that i have found so far:
Php Sends to CMD first so encode userdata in base64 as a transport layer
$rand is a random number to prevent users from useing Success: as a ligitimate user
You will need to clean up the many many spaces that powershell sends back as it is a concole
Special Charicters dont need to be escaped
I am using
Win 2008 RC2
Apache
PHP (of course)
Powershell
Active Directory
PHP Script
$psScriptPath = 'C:/Apache/PSScripts/' //Path outside Website Root $rand = mt_rand(mt_getrandmax(),mt_getrandmax()); //UTF-8 Standard only $username = utf8_decode($_POST["username"]); $password = utf8_decode($_POST["password"]); $base64_username = base64_encode($username); //Transport Layer Base64 $base64_password = base64_encode($password); //Transport Layer Base64 //The danger happens here as it is sent to powershell. $query = shell_exec('powershell.exe -ExecutionPolicy ByPass -command "' . $psScriptPath . '" < NUL -rand "' . $rand . '" < NUL -base64_username "' . $base64_username . '" < NUL -base64_password "' . $base64_password . '" < NUL');// Execute the PowerShell script, passing the parametersPowershell Script #*============================================================================= #* Script Name: adpwchange2014.ps1 #* Created: 2014-10-07 #* Author: #* Purpose: This is a simple script that queries AD users. #* Reference Website: http://theboywonder.co.uk/2012/07/29/executing-powershell-using-php-and-iis/ #* #*============================================================================= #*============================================================================= #* PARAMETER DECLARATION #*============================================================================= param( [string]$base64_username, [string]$base64_password, [string]$rand ) #*============================================================================= #* IMPORT LIBRARIES #*============================================================================= if ((Get-Module | where {$_.Name -match "ActiveDirectory"}) -eq $null){ #Loading module Write-Host "Loading module AcitveDirectory..." Import-Module ActiveDirectory }else{ write-output "Error: Please install ActiveDirectory Module" EXIT NUL Stop-Process -processname powershell* } #*============================================================================= #* PARAMETERS #*============================================================================= $username = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($base64_username)) $password = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($base64_password)) #*============================================================================= #* INITIALISE VARIABLES #*============================================================================= # Increase buffer width/height to avoid PowerShell from wrapping the text before # sending it back to PHP (this results in weird spaces). $pshost = Get-Host $pswindow = $pshost.ui.rawui $newsize = $pswindow.buffersize $newsize.height = 1000 $newsize.width = 300 $pswindow.buffersize = $newsize #*============================================================================= #* EXCEPTION HANDLER #*============================================================================= #*============================================================================= #* FUNCTION LISTINGS #*============================================================================= Function Test-ADAuthentication { Param($Auth_User, $Auth_Pass) Write-Output "Running Function Test-ADAuthenication" $domain = $env:USERDOMAIN Add-Type -AssemblyName System.DirectoryServices.AccountManagement $ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain $pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($ct, $domain) $pc.ValidateCredentials($Auth_User, $Auth_Pass).ToString() } #*============================================================================= #* SCRIPT BODY #*============================================================================= Write-Output $PSVersionTable Write-Output " " $authentication = Test-ADAuthentication "$username" "$password" if ($authentication -eq $TRUE) { Write-Output "Success:$rand Authentication" }elseif ($authentication -eq $FALSE) { Write-Output "Failed:$rand Authentication" }else { Write-Output "Error: EOS" EXIT NUL Stop-Process -processname powershell* } #*============================================================================= #* SCRIPT Exit #*============================================================================= Write-Output "End Of Script" EXIT NUL Stop-Process -processname powershell* Gah, can anyone help. We've written a web app, it was all tested and doing what it should and at the eleventh hour I've hit a snag. We use TCDPF to create printed reports from a MySQL database. It does what it should when accessed over the 'net however I've just been informed that their firewall won't allow Activ X content through and they won't (as opposed to can't) create an exception to trust our site. So, I need a workaround. Option 1) Host a complete copy on their internal network (exceptionally undesirable as it becomes unmanageable). Option 2) Split the printing components out and host that on a web server on their internal network. Option 3) Find another way of producing PDF output from a MySQL web app that can traverse a strict firewall. My preference is for option 2, but I'd like some opinions/thoughts on the best way to proceed before I code myself into a corner once more Thus far I've tried using an include to a different server but it is spitting it's dummy at the moment. Does anyone have any opinions on the *easiest* way to work around the problem? Thanks, Rob Hi All, How would I go about programming a HTML button that cannot be clicked on for two seconds after it loads? As part of a game I wish to stop people simply re-clicking the button and I think a delay of about two seconds would stop abuse of this (if they click it every two seconds then that's fine). I have read the manual for sleep() but it doesn't do exactly what I want - I want the rest of the page to load (and display), and the button to be grayed out for the two seconds, and then the button to be active. James Morning(at least for me anyway) All, I am currently integrating a facebook/style chat system into my webpage. I am going to build the active user list myself but need a little guidance on how to list my users which are online and how to detect when the have gone. When my users login i store only their userid in a session like many login systems. When they login i could simply add their name to a active_users table, but how would i detect whether they are still alive? Any help would be great. Thanks Sam Hi... I am pretty new to ldap and active directory I am creating a site and want to use Active Directory users as the login to the site. This would be the best way to allow everyone to the site and keep the users and passwords up to date. How do you use PHP to talk with Active Directory to do this login? I have read things about LDAP. Do you have to have that? If so, how do you get that to work? and how to configure ldap and where to configure ldap is it server or in my local system. Please give me an idea how to configure n how to integrate active directory This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=355418.0 Hi all Good morning I did connect to the Active Dirctroy using PHP Quote $ldapHost = "ldap://XXX.com"; $ldapPort = "389"; $ldapUser ="XXX@XXX.com"; $ldapPswd ="XXX"; $ldapLink =ldap_connect($ldapHost, $ldapPort) or die("Can't establish LDAP connection"); ldap_bind($ldapLink,$ldapUser,$ldapPswd) or die("Can't bind to server."); it's working well but how can I print the username I mean since I'm connected with Active Dirctory I want any user who enter the webpage it will print his name that stored in Active Dirctory thank you |