Author Topic: Random Topic Button  (Read 12395 times)

0 Members and 1 Guest are viewing this topic.

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Random Topic Button
« Reply #30 on: May 28, 2011, 11:46:53 pm »
can you make it so it only goes to the most recent post in the topic. When I keep using it I seem to continuous go to older posts than the latest one
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Random Topic Button
« Reply #31 on: May 29, 2011, 12:06:48 am »
Seems like http://www.omnimaga.org/index.php?action=.xml;type=rss2 isn't always updated. I'll change it to display the first new post then (the first post in the thread you haven't read).

EDIT: Done.

http://clrhome.co.cc/b/omninew/

Again:

Quote from: PHP
$feed = new DOMDocument();
$feed->load('http://www.omnimaga.org/index.php?action=.xml;type=rss2;limit=100');
$feed $feed->getElementsByTagName('guid')->item(rand(0,99))->nodeValue;
header('Location: ' . substr($feed, 0, strpos($feed, 'msg')) . 'new#new');

I really love this [php] tag :D

EDIT: Update here
« Last Edit: May 29, 2011, 11:21:21 am by Deep Thought »




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Random Topic Button
« Reply #32 on: May 29, 2011, 01:13:18 am »
Nice. I guess the rss not being updated is probably due to it updating itself only every few hours or so.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Random Topic Button
« Reply #33 on: May 29, 2011, 11:19:49 am »
Are you able to get the username of who's going to the page(the user)?
Couldn't you try the parse the new posts page for that? I think that might be easier

Guess I did end up using that. It got really messy, but it means a couple of improvements: it will always be updated (instead of having to wait for the RSS feed to update itself), and you can now choose to avoid your own posts by putting ?avoid=NAME after the URL ;D

http://clrhome.co.cc/b/omninew/?avoid=YOUR+NICK+HERE (http://clrhome.co.cc/b/omninew/?avoid=ruler501 for you, ruler)

Slightly longer this time:

Quote from: PHP
$feed = new DOMDocument();
$feed->loadHTMLFile('http://www.omnimaga.org/index.php?action=ezportal;sa=page;p=5');
$feed $feed->getElementById('block74')->getElementsByTagName('tr');

do
{
    
$item $feed->item(rand(0,99))->childNodes->item(2);
}
while (
strtolower($item->lastChild->previousSibling->nodeValue) == strtolower($_GET['avoid']));

$item $item->firstChild->nextSibling->getAttribute('href');
header('Location: ' . substr($item, 0, strpos($item, 'msg')) . 'new#new');
« Last Edit: May 29, 2011, 12:12:09 pm by Deep Thought »




Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Random Topic Button
« Reply #34 on: May 29, 2011, 11:40:27 am »
Thank you for singling me out for this award Deep Thought :). Maybe someone could add a mod to the site that will put this on the forum page or up on the top and auto ad the users name.

EDIT: Deep Thought while clicking around with it I still see it going to posts that aren't at the bottom. Its going to the first post in this topic http://ourl.ca/11156.new#new

EDIT2: it seems to be doing it on other topics also
« Last Edit: May 29, 2011, 11:50:41 am by ruler501 »
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Random Topic Button
« Reply #35 on: May 29, 2011, 11:56:53 am »
EDIT: Deep Thought while clicking around with it I still see it going to posts that aren't at the bottom. Its going to the first post in this topic http://ourl.ca/11156.new#new

EDIT2: it seems to be doing it on other topics also

It goes to the first new post, the first post you haven't read :) It's like with email notifications.
« Last Edit: May 29, 2011, 11:57:24 am by Deep Thought »




Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Random Topic Button
« Reply #36 on: May 29, 2011, 11:59:34 am »
I don't do email notifs so I wouldn't know, but that makes sense
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Random Topic Button
« Reply #37 on: May 29, 2011, 12:13:51 pm »
Thank you for singling me out for this award Deep Thought :). Maybe someone could add a mod to the site that will put this on the forum page or up on the top and auto ad the users name.

Or host it here. Doesn't really make sense that a random topic script be hosted outside the forum lol




Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Random Topic Button
« Reply #38 on: May 29, 2011, 12:15:42 pm »
I'll keep it bookmarked till it is added into the forums
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Random Topic Button
« Reply #39 on: May 31, 2011, 12:25:53 am »
Is it going to the first post after where you last posted in the topic or to the first unread post? (I still need to try it out, so I'm just trying to clarify.)
At any rate, nice! :D
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Random Topic Button
« Reply #40 on: May 31, 2011, 12:26:59 am »
It goes to the first unread post
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Random Topic Button
« Reply #41 on: June 02, 2011, 11:34:35 pm »
Yep, first unread post. The forum already has a nice feature for that -- http://www.omnimaga.org/index.php?topic=####.new#new goes straight there.




Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Random Topic Button
« Reply #42 on: June 02, 2011, 11:35:21 pm »
DeepThought that link doesn't work :(
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Random Topic Button
« Reply #43 on: June 03, 2011, 11:12:48 am »
That wasn't an actual link. #### stands for the topic number, so it would be http://ourl.ca/11024.new#new for the first new post in this topic.




Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Random Topic Button
« Reply #44 on: June 03, 2011, 11:18:17 am »
I know but I still clicked on it to see what it would do
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y