Black Eagle Team Minishell
Path:
/
home
/
c
/
c
/
p
/
ccpsafy
/
www.old
/
inc
/
[
Home
]
File: style_changer.php
<?php // THIS IS PHP PART 1 OF 3 ************************************* /* * INSTRUCTIONS: Place this first part at the very top of your page I mean * the very top, above the Document Type Declaration (DTD), even above * any whitespace. This is required to properly send the cookie. As a * recommended option, add it to a separate file and include it. */ ?> <?php // PHP STYLE CHANGER CONFIGURATION ###################################################################### // Begin configuration section $cookieName = "ccpsa"; // Choose a name for your cookie $defaut = "SurExposé"; // Enter a default CSS title $style1 = "SousExposé"; // Enter an alternate CSS title $style2 = "Point Gris"; // ADD more titles as needed $style3 = "Labo"; // ADD more titles as needed $style4 = "Zoom"; // ADD more titles as needed $style5 = "tata"; // ADD more titles as needed $chemin = "css/"; // Path to CSS relative to page $extension = "../"; // Leave blank for root-level CSS $extension1 = "../../"; // Leave blank for root-level CSS $extension2 = "../../../"; // Leave blank for root-level CSS $cssdefaut = "common.css"; // Defatult CSS file name $cssstyle1 = "sousex.css"; // Alternate CSS file name $cssstyle2 = "pointgris.css"; // Add more CSS files as needed $cssstyle3 = "labo.css"; // ADD more titles as needed $cssstyle4 = "zoom.css"; // ADD more titles as needed $cssstyle5 = "tata.css"; // ADD more titles as needed // No need to edit below this point unless **ADD**ing files ###################################################################### /* * First we need to determine if the user has the CookiesOk test cookie */ if (!isset($_COOKIE['CookiesOk']) && !isset($_GET['PSC'])) { // Of course it's not set, even on return visits. Here it is set on load setcookie('CookiesOk', '1'); /* * But a refresh is needed, the passed vaiable makes sure this doesn't loop * if cookies are not allowed. This was the tricky part and I got some help * from "ClamCrusher" at SitePoint for this block! And, of course I can't * forget PHP.net (my brain away from home) */ header('Location: ' . $_SERVER['PHP_SELF'] . '?PSC'); exit; /* * If a user doesn't allow cookies and the test cookie isn't set, you can * pass some thing on optionally, else some variables are generated */ } elseif (!isset($_COOKIE['CookiesOk']) && isset($_GET['PSC'])) { $commentLead = "<!--"; // Use to hide link/links for non-cookie users, begin $commentTail = "-->"; // Use to hide link/links for non-cookie users, end // Normally, the idea isn't to display a message but just remove the function $nocookieMsg = "<p>Pour changer l'interface vous devez accepter les cookies</p>"; // Else the cookie is set and the script can execute } else { $commentLead = ""; $commentTail = ""; $nocookieMsg = ""; } /* * Let's define the default style in case cookies aren't supported or for * use upon initial landing, before a selection is made */ $cssFile = "$cssdefaut"; // Got the style cookie? Cool, this will return the data to the user if(isset($_COOKIE["".$cookieName.""]) && !isset($_GET["".$cookieName.""])) { // Redefine the user's default style from the cookie data (from last visit) $cssFile = $_COOKIE["".$cookieName.""]; } /* * The user may not already have the cookie, but it doesn't mean * they can't have one, all they have to do is click the link. * The file must exist ([A] the first method of preventing XSS) */ if(isset($_GET["".$cookieName.""]) && file_exists(''.$chemin.''.$_GET["".$cookieName.""].'')) { setcookie("".$cookieName."", "".$_GET["".$cookieName.""]."", time()+60*60*24*30, '/'); $cssFile = "".$_GET["".$cookieName.""].""; } // Available styles array, this is also to prevent XSS (see below) $pcsStyles = array( ''.$cssdefaut.'',''.$cssstyle1.'',''.$cssstyle2.'',''.$cssstyle3.'',''.$cssstyle4.'',''.$cssstyle5.'',); // **ADD** more to array as needed /* * Let's make sure the file is in the array, and here's how the second method * of preventing XSS works by demanding an exact match of index definitions. * If it doesn't match, they get the default style only */ if(!in_array($cssFile, $pcsStyles) ) { $cssFile = $cssdefaut; } /* * Let's give the style a common name for good browsers like Firefox * (this could be done with associative array as well), if this wasn't * a special experiment page, the selected style could be seen in * View - Page Style. This block also negotiates link elements, etc. * If **ADD**ing style sheets, you'll have to provide the style link as * a list of muliple links, one for each file name. You'll use } elseif { * for each but the last. Switching between two styles with a single link * will no longer be sufficient (see NOTE below) */ if($cssFile == "$cssstyle1") { $cssName = "$style1"; $show_link = "$cssstyle1"; $name_link = "$style1";} elseif ($cssFile == "$cssstyle2"){ $cssName = "$style2"; $show_link = "$cssstyle2"; $name_link = "$style2";} elseif ($cssFile == "$cssstyle3"){ $cssName = "$style3"; $show_link = "$cssstyle3"; $name_link = "$style3";} elseif ($cssFile == "$cssstyle4"){ $cssName = "$style4"; $show_link = "$cssstyle4"; $name_link = "$style4";} else { $cssName = "$defaut"; $show_link = "$cssdefaut"; $name_link = "$defaut";} // Here the variables are combined for forming the dynamic style changer's link unless **ADD***ing (see NOTE below) //$styleLink = "<ul> // <li><a href=\"".$PHP_SELF."?".$cookieName."=".$show_link."\">| Visuel ".$name_link." |</a></li> // </ul>"; /* * O NOTE: If offering multiple style sheets, more than 2, **ADD** mutiple links * R instead of a single link like that shown above. Add links as to block below as * needed and uncomment by removing the two forward slashes before: $styleLink = */ $styleLink = " <a class='gestion' href=\"".$PHP_SELF."?".$cookieName."=".$cssdefaut."\">".$defaut."</a> - <a class='gestion' href=\"".$PHP_SELF."?".$cookieName."=".$cssstyle1."\">".$style1." </a><br/> <a class='gestion' href=\"".$PHP_SELF."?".$cookieName."=".$cssstyle2."\">".$style2."</a> - <a class='gestion' href=\"".$PHP_SELF."?".$cookieName."=".$cssstyle3."\">".$style3."</a> - <a class='gestion' href=\"".$PHP_SELF."?".$cookieName."=".$cssstyle4."\">".$style4."</a>"; // This creates the import statement $pscImport = "<style type=\"text/css\" media=\"screen\" title=\"$cssName\"> @import \"$chemin$cssFile\"; </style>"; $pscImportNiv1 = "<style type=\"text/css\" media=\"screen\" title=\"$cssName\"> @import \"$extension$chemin$cssFile\"; </style>"; $pscImportNiv2 = "<style type=\"text/css\" media=\"screen\" title=\"$cssName\"> @import \"$extension1$chemin$cssFile\"; </style>"; $pscImportNiv3 = "<style type=\"text/css\" media=\"screen\" title=\"$cssName\"> @import \"$extension2$chemin$cssFile\"; </style>"; // Lastly everything is put together into one tiny code snippet $pscLink = "<span class='legende'>Choisissez votre Style d'Interface</span><br/>".$commentLead."".$styleLink."".$commentTail."".$nocookieMsg.""; /* * End of main script (1 of 3) - This can be "included" at the very top of every * page if in separate file. This would actually be recommended */ ?>
©
2020 Black Eagle Team