WebmasterSite.net: PHP scripts to enable your creativity
WSN Links PHP Directory Software
PHP Scripts Webmaster Links Support Forums

Register | Forgot Password

Random Links Malfunction

Version:
printPrint


Page: 1 2

Random Links Malfunction
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/03/05 - 05:07 PM:
quote post
#1
Today I tried adding a toplist that displays 8 random links, and appears on a variety of pages on my site. It worked fine on most pages, but whenever I went to a link details page, the toplist displayed the link of the details page that I was on 8 times. I went to a few other link details pages, and each time, it showed 8 of that link instead of random links.

Here's the toplist code I used:
<CONFIG>links,rand(),8,ascending,,,4,0,0,0,0</CONFIG>

Thanks,
Adam

GameLinks.com
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 04/04/05 - 07:27 AM:
quote post
#2
Link details pages are within the scope of links variables. Thus any links toplist on that page will show the link data for the page rather than the toplist.

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/04/05 - 07:32 AM:
quote post
#3
Why would this operator change based on the page it is on? Shouldn't it be consistant throughout the entire site? It seems strange (and not very useful) to have a rand() operator that doesn't work on all pages, especially since I'm specifically asking for a random link.

I'm basically trying to show random links at the bottom of most of my pages (Random Picks of the Day), but I can't do because the rand() variable isn't working on all pages.

Is there any way to get around this, or put in place some sort of mod that allows rand() to work on all pages?

Adam

Edited by Synozeer on 04/04/05 - 07:55 AM

GameLinks.com
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/05/05 - 09:34 AM:
quote post
#4
I managed to find a workaround that does the job. I use static file generation using this link:

http://www.gamelinks.com/exporter.php?number[1]=8&field[1]=rand()&ascdesc[1]=descending&type[1]=links&template=javascript_export2

and saving to this link:

randomgames.js

All was working good until WSN Links automatically updated the static files. When it updated, it left randomgames.js as a 0 byte file. When I update manually, it works every time, but for some reason when it does it automatically, it doesn't work.

Any ideas?

Adam

GameLinks.com
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 04/05/05 - 06:14 PM:
quote post
#5
It has nothing to do with rand(). I would expect that no links toplists would work on the link details page, since it would be a template variable conflict.

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/06/05 - 08:48 AM:
quote post
#6
All was working good until WSN Links automatically updated the static files. When it updated, it left randomgames.js as a 0 byte file. When I update manually, it works every time, but for some reason when it does it automatically, it doesn't work.


The past 3 times WSN automatically updated the static HTML files, the above worked once and failed twice. Both times it failed and created a 0-byte file it was during the noon static html update, and it successfully created the file only during the midnight update. Would there be any reason for this? Could a visitor be accessing that file during the exact time it's updating it cause a problem? I don't see why it works sometimes and not all the time.

Adam

GameLinks.com
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/06/05 - 09:02 PM:
quote post
#7
I ran a few more tests. It was just a coincidence that it worked at night and didn't during the day update, because this time around (at night), one of my files didn't create properly.

Here's what my static file generation page looks like:

http://www.gamelinks.com/exporter.php?number[1]=8&field[1]=rand()&ascdesc[1]=descending&type[1]=links&template=javascript_export2
http://www.gamelinks.com/exporter.php?number[1]=8&field[1]=rand()&ascdesc[1]=descending&type[1]=links&template=javascript_export2
http://www.gamelinks.com/rssfeed.php?type=links&n...'regular'&title=GameLinks.com

randomgames.js
randomgamestest.js
rss/new-games.xml

During tonights automatic 12 hour static file update, the first one (randomgames.js) ended up as a 0 byte file, while the second (randomgamestest.js) generated properly. By looking at the time stamps, it tried (unsuccessfully) to create randomgames.js first, and then created randomgamestest.js afterwards successfully. The RSS file has always generated properly.

It looks as if WSN Links is coming across something when generating these files that causes it to malfunction. Sometimes it works, sometimes it doesn't. When I generate manually, it works every time, so there appears to be something different going on when it generates automatically every 12 hours.

My javascript_export2.tpl is this:

<!-- BEGIN TOPLIST 10 -->
<CONFIG>links,rand(),8,ascending,,,4,0,0,0,0</CONFIG>
<td width="80" valign="top" align="center" class=<? if (({NUMBER} % 2) == 0) echo "bg1"; else echo "bg2"; ?>>
<strong>
<a href="http://www.webmastersite.net/forums/link.php?action=detail&id={LINKID}">
<img src="http://www.gamelinks.com/thumbnails/{LINKGAMEICON}" name="icon" width="80" height="69" alt="{LINKTITLE}" style="background-color: #0066FF; border:1px solid #000"><br>
<font color="#FFFFFF">{LINKBOOKMARKTITLE}</font></a>
</strong>
</td>
<!-- END TOPLIST 10 -->


Any ideas? I really want to keep this functionality on my site but can't if I have to keep manually updating it.

Edited by Synozeer on 04/06/05 - 09:28 PM

GameLinks.com
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 04/08/05 - 08:20 AM:
quote post
#8
Syonezeer wrote:
Could a visitor be accessing that file during the exact time it's updating it cause a problem?


It's a necessity, PHP can't run without a visitor. A visitor stoping the page load before it completes could cause a problem though, I suppose.

Since rss is a subdirectory, are you sure the main directory doesn't have a chmod issue?

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/08/05 - 09:06 AM:
quote post
#9
No directory chmod issues. I moved them to the javascript directory yesterday (which is 777) and the .js files are 666.

One thing I noticed today is that it generated one of the two files successfully, then a few minutes later that file was a 0 byte file, right before my eyes. Perhaps it's not closing the file correctly, causing it to end up a 0 byte file after a few minutes? Or it's not ending the routine properly? This would explain why the manual works fine and the automatic has problems (if they are indeed running a different subroutine).

Whatever it is, I think it's sucking up a lot of system resources. When it automatically ran today, it crashed my Apache after slowing my server down. It never does that when I do it manually, but when it runs automatically, that's when the problems occur. And I run the manual at busy times, so I don't think it's because of too much traffic.

Another thing I noticed (maybe a coincidence), is that whatever order I put those two files to be generated, the first one generally fails, and the 2nd one is generated correctly.

Unfortunately, I'm going to have to disable this function for my site until/if this problem is fixed.

EDIT: Here's apparently what was going on with my server when it was running the static file generations:

Apr 8 11:55:00 Hawkeye: CRITICAL load 17 - killing unneeded services

The main things taking up the load were Apache and MySQL processes. Pretty much the only PHP I'm running is the site running WSN Links, and that time is when the static file generation runs. Would using the rand() function with lots of links possibly cause this sort of high load?

Thanks,
Adam

Edited by Synozeer on 04/08/05 - 09:28 AM

GameLinks.com
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 04/09/05 - 10:17 PM:
quote post
#10
Again, rand() has no relation to anything. Static generation of any sort is likely to cause a high load during the time it generates. The more of them you do at once, the longer it takes and the more likely people are to not let the page fully load which could cause it to have to try again with the next person increasing the load, I suppose.

Edited by Paul on 04/09/05 - 10:20 PM

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/10/05 - 07:23 AM:
quote post
#11
Again, rand() has no relation to anything. Static generation of any sort is likely to cause a high load during the time it generates. The more of them you do at once, the longer it takes and the more likely people are to not let the page fully load which could cause it to have to try again with the next person increasing the load, I suppose.


What would be the difference then doing it automatically as opposed to doing it manually? When I do it manually, it's done quickly and never has a problem. When it does it automatically, that's when there are problems. Also, when it does it automatically, it's doing it at 1am in the morning. There's not a lot of traffic at that time to the site. When I do it manually, I've done it during the busiest times of the day without a glitch.

It was not working when I had just 2 static files being generated. And it always had problems with the same files, the ones that I was trying to create a set of random links. Would just 2 be enough to overload the system?

Is there some other way I can have these automatically generated other than the way they are now, since the current way doesn't appear to work well with my site?

Thanks,
Adam

GameLinks.com
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 04/10/05 - 06:21 PM:
quote post
#12
If it does it quickly manually, there really shouldn't be a difference. I did just work through a bunch of issues with javascript static generation with someone a few weeks ago though, so is this 3.15 you're using?

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/10/05 - 06:29 PM:
quote post
#13
I'm using 3.14. I didn't want to update yet because there were several things you fixed for me that weren't added to 3.15 yet.

I'm using static file generation to create a .js file, rather than using the javascript export to create it, because I want to use a different template for this file than what the other javascript exports are using, which static file generation let's me do.

GameLinks.com
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004
Total Topics: 32
Total Posts: 142
Posted 04/14/05 - 05:20 AM:
quote post
#14
Just updated to the most recent version, but that didn't fix it.

Is there any way we can choose multiple templates with the javascript export function? The only reason I'm using static file export for this is because I need to use a separate template than what I'm using for my other javascript exports.

GameLinks.com
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6316
Posted 04/14/05 - 10:10 PM:
quote post
#15
It occours to me that using the static export there causes a double URL grabbing, since it grabs exporter.php which in turn grabs the url of a custom template that'd create the toplist needed. Try grabbing it more directly to bypass half of that load, by using
index.php?custom=yes&TID=custom-thetemplate&usewrapper=no&allyourtoplistparamaters

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Search thread for
Download thread as

Page: 1 2



You don't have permission to post.

Please login or register.

   
 
© 2008 Paul Knierim. All rights reserved.