News:

Wondering if this will always be free?  See why free is better.

Main Menu

Topics link list

Started by jarih, June 04, 2004, 02:39:37 AM

Previous topic - Next topic

jarih

Hello,

I made a php script that lists all the topics of this board

http://www.kotka.org/simpleenggen.htm [nofollow]


You can modify the script easily

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
   <title>Untitled</title>
</head>
<body>

<?php

function link_extractor($s) {
  $a = array();
     
   if (preg_match_all('/<a\s+.*?href=[\"\']?([^\"\' >]*)[\"\']?[^>]*>(.*?)<\/a>/i',
                      $s,$matches,PREG_SET_ORDER)) {
    foreach($matches as $match) {
      array_push($a,array($match[1],$match[2]));
    }
  }
  return $a;
}

$start = -20;
$j = 0;
for ($i = 0; $i <= 10; $i++) {
   $start = $start + 20;
   $j++ ;
   echo '<b>'.$j.'<b><br>';
   
   $s = 'http://www.simplemachines.org/community/index.php?board=9.'.$start;

   $page = '';
   $fh = fopen($s,'r') or die($php_errormsg);
   while (! feof($fh)) {
       $page .= fread($fh,1048576);
   }
   fclose($fh);


   $links = link_extractor($page);

   foreach ($links as $link) {
        //image-no, topic-yes
      if ($link[1][1] != 'i' and $link[0][50] == 't') echo '<a href='.$link[0].' target="_blank" >'.$link[1].'</a></br>';

   }

}

?>

</body>
</html>

jarih

a bug :

if ($link[1][1] != 'i'  --> not only image links are ignored but :

<a href = "blaa,blaaa">Link has 'i' as a second character</a>

So the list is uncomplete.

Advertisement: