PDA

View Full Version : Day & Night look


07-13-2000, 11:22 AM
How hard would it be to set things up such that the board had one look during the day and another at night? Not changing much--colors, bbtitle, and on/off icons so that at 6am the day style is seen and at 6pm the night style blinks on. It would be nice if we could set the times. Or does such a hack already exist?

[Edited by Shoe on 07-13-2000 at 08:35 AM]

07-13-2000, 01:32 PM
That... sounds complicated but doable. I'm not sure if it needs this but it sounds like it needs a cron job.

07-13-2000, 02:19 PM
Originally posted by SonnetCelestial
That... sounds complicated but doable. I'm not sure if it needs this but it sounds like it needs a cron job.

hmmm... so maybe I could just copy vb files from a day and a night directory into the forums directory whenever it's 6am or 6pm?

How would I set cron to do this?

[Edited by Shoe on 07-13-2000 at 11:19 AM]

07-13-2000, 03:46 PM
actually, all you need is a different template for each "zone", and change the templates in the html...

this is a simple, but very time-consuming hack. for practically each template call you need a if day then this else do that.

07-13-2000, 04:46 PM
Well, you could setup a cron script (or 2, one for night, other for day) to change the styles stuff

07-13-2000, 06:03 PM
Originally posted by Ed Sullivan
Well, you could setup a cron script (or 2, one for night, other for day) to change the styles stuff

Yes, I think the cron is a good idea. I could just copy over the files in the forum directory. I would also have to force a refresh/relaod of the browser. Does anyone know how to do that off hand? Is there a script I could add to the <head>? Has anyone added js to their pages? Thanks for the feedback and help :) .

07-13-2000, 06:06 PM
Originally posted by Ed Sullivan
Well, you could setup a cron script (or 2, one for night, other for day) to change the styles stuff

Yea it was what I was thinking of but I'm not too sure that is safe. To be honest with you I never had too much faith in designs that revolved around time. I mean they are cool and give your site some personality but to manipulate a DATABASE's style variables daily at a set time interval with live connections is asking for a forum boo boo. I'd say the cron script should first shut down the forum (or connections) before it changes the variables, although the best way to do this safely is by hand. I'd wait until they get the software wrinkles ironed out (not to mention learn A LOT more about databases) before fooling around with forum manipulating cron scripts. Ed would know a lot more about me, I'm just a php newbie! :p

07-13-2000, 06:57 PM
Well, although you'd be increasing your chance of getting an error if you didn't shut off the forum to change the colors, IMO, it's the equivalent of adding a post to the post table.

This is just coming off the top of my head, so I wouldn't count on it working:
<?php

$DB_site->query("UPDATE replacement SET replaceword='<b><FONT face=\"verdana, arial, helvetica\" size=\"4\" color=\"#000000\"' WHERE findword='<largefont'");
$DB_site->query("UPDATE replacement SET replaceword='<body bgcolor=\"#ffffff" text=\"#959595">' WHERE findword='<body>'");

//etc.... I don't feel like going all the way now

?>

Of course, it gets a little more complex as you try and replace certain options.

[Edited by Ed Sullivan on 07-13-2000 at 03:57 PM]

07-14-2000, 07:55 AM
I think if you are wanting to do this then you shouldn't go and change the actual variables themselves it would be best to do it dynamically. i.e. get each script to look at the time and then put the appropriate colour variables into it.

It is extremely complicated though unless you know every visitor to your site is in the same part of the world, to work properly you would have to get them to input their latitude and longditude and correct current timezone and have access to forumulas which will calculate sunrise and sunset times for everywhere around the world - not an easy task.

07-14-2000, 01:47 PM
Originally posted by Mark Hewitt
I think if you are wanting to do this then you shouldn't go and change the actual variables themselves it would be best to do it dynamically. i.e. get each script to look at the time and then put the appropriate colour variables into it.

It is extremely complicated though unless you know every visitor to your site is in the same part of the world, to work properly you would have to get them to input their latitude and longditude and correct current timezone and have access to forumulas which will calculate sunrise and sunset times for everywhere around the world - not an easy task.

Umm.. I would just go for a javascript function to check the person's local time (aka time on their computer)then check it but that's just me. :) (and if I REALLY took the lazy route out, I would just stick to server time ;))

[Edited by SonnetCelestial on 07-14-2000 at 10:49 AM]

07-15-2000, 02:16 AM
Thanks for all the feedback. maybe it is more trouble than it's worth but I thought it would be a nice touch to have a day vs a night look.

07-15-2000, 05:44 PM
This can be done rather easily, except for the bbtitle and posting images. If you can live without those, you're good to go...

Actually, you _can_ do it with those images as well :)

Here's how.

Open up global.php (not in the admin dir), and look for:
// load vars
$vars=$DB_site->query("SELECT * FROM replacement ORDER BY replacementid DESC");
Replace with:
if (date("G") < 18 && date("G" > 6) {
// load vars
$vars=$DB_site->query("SELECT * FROM replacement ORDER BY replacementid DESC");
}
Look for:
$DB_site->data_seek(0,$vars);
while ($var=$DB_site->fetch_array($vars)) {
$newtext=str_replace($var[findword],$var[replaceword],$newtext);
}
Replace with:
if (date("G") < 18 && date("G" > 6) {
$DB_site->data_seek(0,$vars);
while ($var=$DB_site->fetch_array($vars)) {
$newtext=str_replace($var[findword],$var[replaceword],$newtext);
}
} else {
$newtext=str_replace("<body>,"<body bgcolor=dark>",$newtext);
$newtext=str_replace("<largefont,"<font color=dark",$newtext);
$newtext=str_replace("</largefont>","</font>",$newtext);
etc...
}
The entire else statement should be a manual duplication of the normal dovars subroutine, so go look in your replacements table, and do what I started, except change the values and colors to what you want it to look like at night.

You can also add bbtitle.gif to the first variable in str_replace, and use the darktitle.gif name in the second variable. This will replace that image, and you can do the same for newpost, postreply, etc.

Ask if you have any questions.

Oh, and this was coded in my web browser, so there might be one or two stupid errors. :)

07-16-2000, 02:00 PM
That seems a lot of clart on when you can just put replacement variables in the header!

08-11-2000, 09:57 PM
"It is extremely complicated though unless you know every visitor to your site is in the same part of the world, to work properly you would have to get them to input their latitude and longditude and correct current timezone and have access to forumulas which will calculate sunrise and sunset times for everywhere around the world - not an easy task."

No, actually it would be possible to do something like visualtraceroute.datametrics.org on a couple of packets. Using that info it could customize it. It could also ask for the users time zone and customize it for each user.