Jump to content
House Price Crash Forum

Archived

This topic is now archived and is closed to further replies.

pl1

Any P H P Programmers Here?

Recommended Posts

Any PHP coders here (maybe Javascript would work) who could write a small program to take a thread on HPC go through all the pages and generate a table with Username and Number of Posts in the thread?

I know it can be done. Or alternatively any tool that can do the same thing?

Share this post


Link to post
Share on other sites

Any PHP coders here (maybe Javascript would work) who could write a small program to take a thread on HPC go through all the pages and generate a table with Username and Number of Posts in the thread?

I know it can be done. Or alternatively any tool that can do the same thing?

Could be done with a number of tools. PHP wouldn't be my choice. Cost yer though.

Share this post


Link to post
Share on other sites

Could be done with a number of tools. PHP wouldn't be my choice. Cost yer though.

Okay I'll settle for just knowing which tools and try to work it out. :lol:

Why not PHP I thought that was the darling of the Web?

Share this post


Link to post
Share on other sites

Okay I'll settle for just knowing which tools and try to work it out. :lol:

Why not PHP I thought that was the darling of the Web?

Hehehe. I wouldn't say that!

And it's more appropriately a task for a browser tool (unless you're responsible for the HPC website itself). OTTOMH, greasemonkey would be a startingpoint.

Share this post


Link to post
Share on other sites

Any PHP coders

I'm not a professional but this should do the job...

<?php/* Requires PHP Safe Mode to be turned off for   large threads as time limit can overrun */set_time_limit(0);/* Sleep time between page requests,   in order to prevent stress on server */define('REQUEST_TIMER', 2);?><html><body><?phplist($ForumUrl, $ThreadUrl) = GetUrlInformation($Url);/* Request index page and update users   on this page */$IndexContents = file_get_contents($ThreadUrl);if (!$IndexContents) die('Couldn\'t get contents of thread index page!');else{ $Users = array(); GetUsers($IndexContents, $Users); /* Request additional pages and update users     on each additional page */ list($PageCount, $PagePosts) = GetPageCount($IndexContents); for ($i = 1; $i < $PageCount; $i++) {   $PageUrl = $ThreadUrl . '&st=' . $PagePosts * $i;   $PageContents = file_get_contents($PageUrl);   if (!$PageContents)     echo 'Couldn\'t get contents of thread page number ' . $i;   else     GetUsers($PageContents, $Users);   sleep(REQUEST_TIMER); // Chill momentarily before making another request } /* Sort users by post count in ASC order    using our own comparison function */ uasort($Users, "UserComparison"); // Display title $Success = GetTitle($IndexContents, $Title); if ($Success)   echo '<h1>' . $Title . '</h1>'; echo '<div style="padding:20px;">'; // Display users   foreach ($Users as $UserId => $UserDetails)     UserDisplay($UserId, $UserDetails); echo '</div>';}// Get the forum and thread urlfunction GetUrlInformation($Url){ if (!$Url) // Don't forget to add ?Url=MY_THREAD_URL   die('No url provided!'); $Matched = preg_match("/^(.*)\/index.php\?showtopic=([0-9]+)/", $Url, $Results); if (!$Matched)   die('No topic id found from url, bad url?'); return array($Results[1], $Results[1] . '/index.php?showtopic=' . $Results[2]);}// Get the title of the topicfunction GetTitle(&$PageContents, &$Title){ $Success = preg_match("/<title>(.*)<\/title>/", $PageContents, $Results); if (!$Success)   return false; $Title = $Results[1]; return true;}// Get or update users on a pagefunction GetUsers(&$PageContents, &$Users){ if ($NumMatches = preg_match_all('/author vcard.*showuser=([0-9]+)\'>([^>]+)<\/a>/i', $PageContents, $Matches, PREG_SET_ORDER)) {   $i = 0;   while ($i < $NumMatches)   {     $UserId = $Matches[$i][1];     $UserName = $Matches[$i][2];     // Add user or increment existing user post count     if ($Users[$UserId])       $Users[$UserId]['Posts']++;     else       $Users[$UserId] = array('Name' => $UserName, 'Posts' => 1);     $i++;   } }}// Get the page count and number of posts per pagefunction GetPageCount(&$PageContents){ $Success = preg_match("/perPage: ([0-9]+), totalPages: ([0-9]+)/", $PageContents, $Results); if (!$Success)   return 1; return array($Results[1], $Results[2]);}// Comparison function for sortingfunction UserComparison($x, $y){ if ($x == $y)   return 0; return ($x['Posts'] > $y['Posts']) ? -1 : 1;}// Output each user, a link to their profile and the number of posts in the threadfunction UserDisplay($UserId, $UserDetails){ global $ForumUrl; echo '<div style="float:none; padding:5px;">';   echo '<div style="width:300px; float:left;">';     echo '<a href="' . $ForumUrl . '/index.php?showuser=' . $UserId . '">' . $UserDetails['Name'] . '</a></div><div>' . $UserDetails['Posts'];   echo '</div>' . "\n"; echo '</div>';}?></body></html>

Share this post


Link to post
Share on other sites

Any PHP coders here (maybe Javascript would work) who could write a small program to take a thread on HPC go through all the pages and generate a table with Username and Number of Posts in the thread?

Like this?

n9nqe.jpg

Share this post


Link to post
Share on other sites

Like this?

n9nqe.jpg

Not only is that it, but it's for the thread I wanted to check :lol:

Is that a built in feature of the board coz the window skin looks the same?

edit: ta!

edit2: I've just worked it out, you click replies. Although sounds obvious I never thought to try until you nudged my brain.

Share this post


Link to post
Share on other sites

Not only is that it, but it's for the thread I wanted to check :lol:

Is that a built in feature of the board coz the window skin looks the same?

edit: ta!

edit2: I've just worked it out, you click replies. Although sounds obvious I never thought to try until you nudged my brain.

The board has many secrets. I'd seen these links hundreds of times before it occurred to me to click on one. Imagine my surprise when I found out what it did.

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

  • 312 Brexit, House prices and Summer 2020

    1. 1. Including the effects Brexit, where do you think average UK house prices will be relative to now in June 2020?


      • down 5% +
      • down 2.5%
      • Even
      • up 2.5%
      • up 5%



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.