37 public $browseList = array();
38 public $noRows = FALSE;
39 public $emptyTable = FALSE;
42 protected $anchors = array();
46 function __construct($page,$tblId,$title=1)
48 if (empty ($page)) {
return; }
50 if (strlen($tblId) == 0) {
return; }
51 $this->tableId = $tblId;
52 $this->title = $title;
90 $parts = explode(
': ', $nodeString);
94 $uploadName = $parts[1];
101 function fromFS($nodeString)
103 $parts = explode(
': ', $nodeString);
105 $uploadName = pathinfo($parts[1], PATHINFO_FILENAME);
106 if(strlen($uploadName) != 0)
114 function fromURL($nodeString)
116 $parts = explode(
': ', $nodeString);
118 $urlParts = parse_url($parts[1]);
119 $uploadName = pathinfo($urlParts[
'path'], PATHINFO_FILENAME);
124 function getAnchors($node, $uploadName)
126 $anchorList = $node->getElementsByTagName(
'a');
127 foreach($anchorList as $anchorEle)
129 $anchorText = $anchorEle->textContent;
132 $this->anchors[$uploadName][$anchorText] = $anchorEle->getAttribute(
'href');
136 function parseBrowseMenuFiles()
139 $dom =
new domDocument;
140 @$dom->loadHTML($this->page);
142 $dom->preserveWhiteSpace =
false;
143 $table = $dom->getElementById($this->tableId);
145 $this->emptyTable = TRUE;
146 print
"DPLTDB: table is empty, can't find table! with table id of:$this->tableId\n";
147 return($this->browseList=array());
150 foreach ($table->childNodes as $tblChildNode)
152 if($tblChildNode->nodeName ==
'tr')
154 $childNodes = $tblChildNode->childNodes;
155 $clen = $childNodes->length;
156 for($i=0; $i<$clen; $i++)
158 $node = $childNodes-> item($i);
159 $nn = $node->nodeName;
160 if($node->nodeName ==
'td')
162 $fileName = $node->nodeValue;
163 $childNodes = $node->childNodes;
164 $tdclen = $childNodes->length;
165 for($i=0; $i<$tdclen; $i++)
167 $tdnode = $childNodes->item($i);
168 $tdnn = $tdnode->nodeName;
172 $tdNodeValue = $tdnode->nodeValue;
175 $fromFS =
'Added from filesystem:';
176 $fromFile =
'Added by file upload:';
177 $fromURL =
'Added by URL:';
181 if($matches = preg_match(
"/$fromFile/",$tdNodeValue,$ffMatch))
183 $fileUploadName = $this->
fromFile($tdNodeValue);
184 $this->getAnchors($node, $fileUploadName);
186 else if($matches = preg_match(
"/$fromFS/",$tdNodeValue,$fsMatch))
188 $fsUploadName = $this->fromFS($tdNodeValue);
189 $this->getAnchors($node, $fsUploadName);
191 else if($matches = preg_match(
"/$fromURL/",$tdNodeValue,$urlMatch))
193 $urlUploadName = $this->fromURL($tdNodeValue);
194 $this->getAnchors($node, $urlUploadName);
201 if(!empty($this->anchors))
203 $this->browseList = array_merge($this->browseList, $this->anchors);
204 $this->anchors = array();
208 if(empty($this->browseList)) {
209 $this->noRows = TRUE;
227 $matches = preg_match_all(
"/.*?\[<a href='(.*?)'.*?>([V|I|Down].*?)</", $this->page, $fileMini, PREG_PATTERN_ORDER);
228 print
"fileMini Menus are:";
229 print_r($fileMini) .
"\n";
242 $matches = preg_match_all(
"/.+class='mono'.*?<a href='(.*)'>(.*?)<\/a>/", $this->page, $dirs, PREG_PATTERN_ORDER);
245 return ($this->_createRtnArray($dirs, $matches));
248 function _createRtnArray($array, $matches)
256 $numMenus = count($array[1]);
258 for ($i = 0; $i <= $numMenus -1; $i++)
260 $rtnList[$array[2][$i]] = $array[1][$i];
291 $numMenus = count($array[1]);
292 $loopCnt = $numMenus / 3;
296 for ($i = 0; $i <= $loopCnt -1; $i++)
299 for ($j = 0; $j <= 2; $j++)
301 $triple[$array[2][$j]] = $array[1][$index];
304 $rtnList[$i] = $triple;