how to stop a function in a twice-included file?

i'm using a sniffer to detect a user's browser and include a content file twice if it's Internet Explorer (for fairly esoteric reasons i won't go into here).

how do i stop a function from being declared twice in this way??
index.phpfunction addIEContent()
{
global $isIewin;
if ($isIewin == "true")
{include("content/content_".$p.".php");
}
}

addIEContent();
(function from content file that is being included)<?php number("full5"); ?>
example
<!-- m --><a class="postlink" href="http://meat-thing.com/mars/?p=Download">http://meat-thing.com/mars/?p=Download</a><!-- m -->

TIA...I don't see where you are doing it twice?

you have 1 function so where is the other one?sorry, i wasn't very clear... it's being included once, and then included again if the browser is IE (it's that translucent thing again). the same file is included twice for IE, once for other browsers.

if you don't remember the reason why i include the same content twice (layering opaque content over alpha-filtered content, the CSS of which which is damnably inherited), then it really doesn't matter... all i can say is that it works well EXCEPT for when i need to declare a function in the included file.so instead of include you can use include_once()

is that what you meant? I remember why and how come but I just don't see it with that little code.i thought about doing that (in fact i'm only including the problem content once right now, but that makes the whole page hard to read at lower alpha levels in IE), but the rest of the content needs to be included twice... i'm baffled how to get around this. another problem is that the first include will be @ <50% alpha, where the second time round it will be opaque... but i'm willing to live with a funky looking link (that's what the thing is doing, generating links).

here's what it looks like now
<!-- m --><a class="postlink" href="http://meat-thing.com/mars/?p=Download">http://meat-thing.com/mars/?p=Download</a><!-- m --> so you don't want that blue around it?yeah, the only thing that's being included twice is the content inside the translucent boxes. so i want all of that stuff, i'd just prefer to have that page look like the other pages, i.e., the text at 100% opacity rather than inheriting the alpha value of the cell or div or whatever i'm doing there.ok, can I see the script that runs this?

seems like you are doing this "addIEContent();" twice righthere's the index pagehere's the content fileOriginally posted by scoutt
ok, can I see the script that runs this?

seems like you are doing this "addIEContent();" twice right only if $browser == IE/Win
(or whatever it is - however i have it written, i don't remember right now)
if browser != IE/Win, then it's not adding in the content again.

addIEContent() is only to slap the 2nd, IE-only opaque layer on top of the translucent one only if the browser happens to be IE on Win.ok, I am being retarded here. I have actually Download ed your scripts from your site and looking through them I don't see how they work. you included all the css in all of them. you do know they combine to make 1 big css file right?

I understand the logic but not sure I understand what is being set. I don't see anywhere in the css file that makes the background that color on the links. can you tell me where?

also it would be cool if you can set it so the style they ar on is listed somewhere so they know exactly what style is being used. maybe have that drop down be the one that is set in the cookie?

afer loking a little bit closer I see you have some code running twice.

in files sniff_misc.php and sniff_css.php.

I would take the functions out of sniff_css.php and leasve them in the other one. otehr than that I don't see any place you are doing it twice.Originally posted by scoutt
ok, I am being retarded here. I have actually Download ed your scripts from your site and looking through them I don't see how they work. you included all the css in all of them. you do know they combine to make 1 big css file right?no, those are ALTERNATE stylesheets. in GOOD browsers, like Mozilla, you can switch the stylesheets on-the-fly with the "view" menu on the toolbar. a handy feature, though it doesn't quite work perfectly with MARS s.t.s. because of the wrapper system.

Originally posted by scoutt
I understand the logic but not sure I understand what is being set. I don't see anywhere in the css file that makes the background that color on the links. can you tell me where?
it's dynamic, look in sniff_css.php for what gets inserted into the css file.

Originally posted by scoutt
also it would be cool if you can set it so the style they ar on is listed somewhere so they know exactly what style is being used. maybe have that drop down be the one that is set in the cookie?yeah, i want to do something like that, just haven't gotten around to figuring it out yet.

Originally posted by scoutt afer looking a little bit closer I see you have some code running twice.

in files sniff_misc.php and sniff_css.php.

I would take the functions out of sniff_css.php and leave them in the other one. other than that I don't see any place you are doing it twice. the function i'm having problems with isn't in the zip file, because i only needed it on the Download page. it's a Download counter called "downi" and the function is called in the file content_Download .php (see above attachement). here's the function file for downi:only place I can see you doing it twice is when you included the function fil ein the content_Download script.

either take i tout or put it in the mars
script.

try thatexactly. the content_Download .php file is the one being included twice if the browser is IE (ALL content_(name).php files are being included twice, if $p is set to the name of the content file).

so it goes

-----------
blah blah blah

(include content)

if $browser == Win/IE
(include content again directly on top of previous included content)
-----------

if the content that's being included happens to be content_Download .php, then it will have the function in question in it. if it is viewed in IE under Windows, then the content will be included twice and the function will break.i can't believe it was this simple. actually, i'd been trying to avoid going this route, but it suddenly occurred to me that this is the easiest way.// content start
if (isset($p))
{
if ($p == "Download " && $isIewin == "true") // hack for IE so as not to redeclare the downi function
{
include("content/content_Download _alt.php");
}
else {
include("content/content_".$p.".php");
}
}
else
{
include("content/content.php");
}
// END contentwhere content_Download _alt.php does NOT contain the number() declaration (just everything else).

so, if the page called is $p=Download , and the sniffer says that $browser=iewin, then the FIRST content to be included is DIFFERENT all of a sudden (all other pages and all other browsers act normally), and instead an alternate content page is delivered FIRST (@ < 100% opacity) (this one does NOT include the function), and THEN the second, NORMAL content is included over top.

works a charm, too! (<!-- m --><a class="postlink" href="http://www.meat-thing.com/mars/?p=Download">http://www.meat-thing.com/mars/?p=Download</a><!-- m --> )or by using include_once()

that will not have included it if it has already been included. but your way works as well, good job.Originally posted by scoutt
or by using include_once()

that will not have included it if it has already been included. but your way works as well, good job. actually, i did try that, but including it once meant that just the first, semi-transparent text showed. that's when i finally got off my ass and DID something about it.
 
Back
Top