Xepher.Net Forums

Xepher.net => Technical Support => Topic started by: crescens on July 03, 2007, 01:26:36 AM

Title: Yet another newsbox problem
Post by: crescens on July 03, 2007, 01:26:36 AM
Sorry for being a bother again.
I was trying to incorporate the newsbox into my page, but for some reason, whenever I include it, the rest of my script breaks. :/
It works perfectly without the newsbox, and I'm just not sure where the problem is, because there are parts of the script that includes other pages, and it works fine.
Here's the page: http://crescens.xepher.net/fish/index.php

Any help would be appreciated, thanks.

Title: Re: Yet another newsbox problem
Post by: Databits on July 03, 2007, 01:29:15 AM
I wonder... is the news box included PHP? If so, did you make sure that you aren't duplicating any variables that it sets or uses?

Also, I'm noticing a javascript function call in the body onload handler called "goforit()", but the javascript function isn't defined anywhere.
Title: Re: Yet another newsbox problem
Post by: crescens on July 03, 2007, 01:34:03 AM
I'm... actually not sure what that does either.
Well, I got rid of it, and it didn't make a difference. :/
Title: Re: Yet another newsbox problem
Post by: Databits on July 03, 2007, 01:35:47 AM
Also note that:
<a class=newsbox href=# onClick="top.location.href = document.siteselector.sitelist.options[document.siteselector.sitelist.selectedIndex].value;">Go</a>
is incorrect (X)HTML...

Instead it should be this (you are missing the quotes):
<a class="newsbox" href="#" onClick="top.location.href = document.siteselector.sitelist.options[document.siteselector.sitelist.selectedIndex].value;">Go</a>

Also, could you copy the index.php to something like index2.php and remove the newsbox so I can see a working copy of the script?
Title: Re: Yet another newsbox problem
Post by: crescens on July 03, 2007, 01:43:20 AM
I... honestly don't even know where that line is, so I don't know how to fix it. D:

Here is the working script: http://crescens.xepher.net/fish/index2.php

All I did was remove this:
Quote<?php include "/home/httpd/htdocs/newsbox.php" ?>
Title: Re: Yet another newsbox problem
Post by: Databits on July 03, 2007, 01:46:08 AM
Ok, I'm willing to bet that somewhere in there is a variable conflict of some sort... strange that it's not spitting a PHP error to the screen or anything though.

Yeah... after doing a dump on that particular script it looks like it'd be quite easy for another program to use some of the things that it writes. So I'm gonna write you a quick thing to try out... gimme a sec.
Title: Re: Yet another newsbox problem
Post by: Databits on July 03, 2007, 01:53:58 AM
Hmm my account here seems to have been locked, sorry can't help atm but try this anyhow:

<?php function renderXepherNewsbox() { include "/home/httpd/htdocs/newsbox.php"; } renderXepherNewsbox(); ?>

Now to explain what this is doing. Since you're including the script on a global level, it's (re)defining the variables in that script on a global level. What I did was wrapped it in a function, which should make the variables exclusive to that function alone, keeping the global values safe.
Title: Re: Yet another newsbox problem
Post by: crescens on July 03, 2007, 02:00:34 AM
Oh, it works!! :D :D
But... now all the visual configuration is gone.  Is there any way to incorporate those, or am I asking or too much?
Title: Re: Yet another newsbox problem
Post by: Databits on July 03, 2007, 02:01:44 AM
Add them into the function call at the top:

<?php
function renderXepherNewsbox() {
  
// Place your configuration constants here...

  
include "/home/httpd/htdocs/newsbox.php";
}
renderXepherNewsbox();
?>
Title: Re: Yet another newsbox problem
Post by: Xepher on July 03, 2007, 03:14:44 AM
Hmm, I'll have to be more careful with code when I rewrite the newsbox. Glad ya'll got it figured out though.
Title: Re: Yet another newsbox problem
Post by: griever on July 03, 2007, 06:51:22 AM
I don't mean to sound naggy, Xepher, but with the new newsbox, could you also have HTML that validates?  I ran mine though the validator (http://validator.w3.org) and the majority of errors were from the newsbox (at least 450 of them).
Title: Re: Yet another newsbox problem
Post by: crescens on July 03, 2007, 07:28:02 AM
Actually... it's still not working fully with the script...
http://crescens.xepher.net/fish/

:/

And once again, it's perfectly fine without the box: http://crescens.xepher.net/fish/index2.php
Title: Re: Yet another newsbox problem
Post by: Databits on July 03, 2007, 02:32:29 PM
Did you put the configuration stuff in the function like I told you?
Title: Re: Yet another newsbox problem
Post by: crescens on July 03, 2007, 05:30:56 PM
Well, the thing was it was working perfectly without it, and it broke as soon as I put it in, so I tried removing it to see if it's better.  And for some reason, it isn't. :/
Title: Re: Yet another newsbox problem
Post by: Databits on July 03, 2007, 06:28:53 PM
what exactly is the code when you add the newsbox config stuff to it?
Title: Re: Yet another newsbox problem
Post by: crescens on July 03, 2007, 07:47:24 PM
Quote<?php function renderXepherNewsbox() {
//Newsbox config section, may be placed anywhere in the page above the newsbox

//All colors are quoted html-style colors, such as "#ffffff" for white, or "#000066" for dark blue
$border_color = "#b9a894" ;
$background_color = "#ffffff" ;
$text_color = "#718E86" ;
$button_background_color = "#ffffff" ;
$button_text_color = "#718E86" ;
$highlight_text_color = "#666666" ;
$title_text_color = "#000000" ;
$title_background_color = "#ffffff" ;
$link_text_color = "#718E86";

//Other Visual Options

$box_width = "200" ;
//Newsbox width measured in pixels. Values between 150 and 400

$border_width = "0" ;
// Border width measured in pixels, 0 for none

$align_box = "none" ;
//Which side to place the newsbox, with the rest of the page flowing around it. Can be "left", "right", or "none" to disable wrapping


//Display Config

$show_news = 0 ;
//Set to 0 to disable site news, 1 to show it. See "newsfile" option below

$news_file = "./news.txt" ;
//Text file to include for site news, note that the news "date" is set to the last modification date of this file.

$show_announcements = 0 ;
// Set to 0 for imporant only, 1 for normal

$show_feature = 1 ;
//Set to 0 for none, 1 for on

$show_nav_box = 1 ;
//Set to 0 for none, 1 for default list (auto-generated), 2 for custom list (see below)

$custom_nav_list = "xepher user otheruser" ;
//Space-seperated list of usernames to be linked in the nav-box. Add your favorite Phase 2 sites.

$show_hits = 1 ;
//Set to 0 for off, 1 for on

//End Config
include "/home/httpd/htdocs/newsbox.php";
} renderXepherNewsbox(); ?>
Title: Re: Yet another newsbox problem
Post by: Xepher on July 03, 2007, 09:06:47 PM
Alright, I just rewrote half the newsbox code to give safe variable names... but to keep compatibility with everyone who's already got it setup and working (aka everyone) you have to add an option.

First, add this line to the top of the config section.

$XN_Newsbox_safe_mode=1;

Then preface all the existing config variables with "$XN_Newsbox_" e.g. "$box_width" becomes "$XN_Newsbox_box_width"

That should solve your problems, and let you forgo the function-wrapping Data's got you trying. As for the newsbox not validating... well, that's not just a search/replace sort of rewrite, but would require a fundamental design change in how the newsbox works. The reason/problem is that w3c doesn't allow CSS outside of the document head, but by the time the newsbox is included, head is already closed. The two options to fix that would involve having another code section people would have to place specifically in the head section of their pages, or I would have to rewrite the whole newsbox to use inline CSS. Obviously, the second option is preferable from a point of view of "correctness" and easiness, but is more work than I'm currently willing to put in for already obsolete code.

The new newsbox system will be completely different from the ground up, and while writing, I do intend to make sure it validates.
Title: Re: Yet another newsbox problem
Post by: crescens on July 03, 2007, 09:16:26 PM
Sorry for the trouble, but that... didn't seem to make a difference. :(
Can I maybe leave the newsbox out until the new version is ready to be used?
Title: Re: Yet another newsbox problem
Post by: Xepher on July 03, 2007, 09:37:39 PM
Okay, so the problem has nothing to do with variable collisions. Quite simply, whatever that script/software your using is doing something rather stupid and probably dangerous too... None of the mysql query functions specify what database connection to actually use, so it just defaults to "the last one used." As the newsbox does SQL queries, your scripts start trying to lookup info in the XN user database after it's included, rather than your own database. That's not something that's going to be fixed by w3c valid css or other fix to the newsbox. The "SomeryC" scripts you're using are simply coded in a poor way, much like the newsbox variables were. I've rewritten that side of things, but you'll have to rewrite the other side to fix this.

The one other option is to make a separate page, with nothing but the newsbox on/in it, then include that as an iframe on your real page. If you do it right, with no scroll bars or anything, it'll look just the same. That's probably the easiest solution for now. The new newsbox is several months off at least, and I'm still not decided on exactly how it'll function, or what resources it'll use. That is to say, I don't know if it'll have this same problem or not. I don't THINK it will, but we'll see once I get more ideas solidified for it.
Title: Re: Yet another newsbox problem
Post by: crescens on July 03, 2007, 10:01:58 PM
Alright, I'll do that.
I really don't think I can rewrite the script if I tried, but I'll report the problem on their forum and see how they respond.  Thanks for everything.