FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
parsePgLinks.php
1 <?php
2 
3 
4 /***********************************************************
5  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License
9  version 2 as published by the Free Software Foundation.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  ***********************************************************/
20 
35 {
36  public $page;
37  private $test;
38 
39  function __construct($page)
40  {
41  if (empty ($page))
42  {
43  return;
44  }
45  $this->page = $page;
46  }
57  function parsePgLinks()
58  {
59  // The line below is great for pasring hrefs out of a page, from the net
60  $regExp = "<a\s[^>]*href=(\'??)([^\'>]*?)\\1[^>]*>(.*)<\/a>";
61  $matches = preg_match_all("|$regExp|iU", $this->page, $links, PREG_SET_ORDER);
62  print "links are:\n";
63  print_r($links) . "\n";
64  //$lstFilesLic[] = $this->_createRtnArray($pathList, $matches);
65  //return ($lstFilesLic);
66  }
67  function _createRtnArray($list, $matches)
68  {
69  /*
70  * if we have a match, the create return array, else return empty
71  * array
72  */
73  if ($matches > 0)
74  {
75  $numPaths = count($list[3]);
76  //print "numPaths is:$numPaths\n";
77  //print "list is:\n";
78  //print_r($list) . "\n";
79 
80  $rtnList = array ();
81  for ($i = 0; $i <= $numPaths -1; $i++)
82  {
83  $cleanKey = trim($list[3][$i], "\/<>b");
84  $rtnList[$cleanKey] = $list[2][$i];
85  }
86  return ($rtnList);
87  } else
88  {
89  return (array ());
90  }
91  }
92 }
93 ?>
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:695