26 public $browseList = array();
27 public $noRows = FALSE;
28 public $emptyTable = FALSE;
31 protected $anchors = array();
35 function __construct($page,$tblId,$title=1)
37 if (empty ($page)) {
return; }
39 if (strlen($tblId) == 0) {
return; }
40 $this->tableId = $tblId;
41 $this->title = $title;
79 $parts = explode(
': ', $nodeString);
83 $uploadName = $parts[1];
90 function fromFS($nodeString)
92 $parts = explode(
': ', $nodeString);
94 $uploadName = pathinfo($parts[1], PATHINFO_FILENAME);
95 if(strlen($uploadName) != 0)
103 function fromURL($nodeString)
105 $parts = explode(
': ', $nodeString);
107 $urlParts = parse_url($parts[1]);
108 $uploadName = pathinfo($urlParts[
'path'], PATHINFO_FILENAME);
113 function getAnchors($node, $uploadName)
115 $anchorList = $node->getElementsByTagName(
'a');
116 foreach($anchorList as $anchorEle)
118 $anchorText = $anchorEle->textContent;
121 $this->anchors[$uploadName][$anchorText] = $anchorEle->getAttribute(
'href');
125 function parseBrowseMenuFiles()
128 $dom =
new domDocument;
129 @$dom->loadHTML($this->page);
131 $dom->preserveWhiteSpace =
false;
132 $table = $dom->getElementById($this->tableId);
134 $this->emptyTable = TRUE;
135 print
"DPLTDB: table is empty, can't find table! with table id of:$this->tableId\n";
136 return($this->browseList=array());
139 foreach ($table->childNodes as $tblChildNode)
141 if($tblChildNode->nodeName ==
'tr')
143 $childNodes = $tblChildNode->childNodes;
144 $clen = $childNodes->length;
145 for($i=0; $i<$clen; $i++)
147 $node = $childNodes-> item($i);
148 $nn = $node->nodeName;
149 if($node->nodeName ==
'td')
151 $fileName = $node->nodeValue;
152 $childNodes = $node->childNodes;
153 $tdclen = $childNodes->length;
154 for($i=0; $i<$tdclen; $i++)
156 $tdnode = $childNodes->item($i);
157 $tdnn = $tdnode->nodeName;
161 $tdNodeValue = $tdnode->nodeValue;
164 $fromFS =
'Added from filesystem:';
165 $fromFile =
'Added by file upload:';
166 $fromURL =
'Added by URL:';
170 if($matches = preg_match(
"/$fromFile/",$tdNodeValue,$ffMatch))
172 $fileUploadName = $this->
fromFile($tdNodeValue);
173 $this->getAnchors($node, $fileUploadName);
175 else if($matches = preg_match(
"/$fromFS/",$tdNodeValue,$fsMatch))
177 $fsUploadName = $this->fromFS($tdNodeValue);
178 $this->getAnchors($node, $fsUploadName);
180 else if($matches = preg_match(
"/$fromURL/",$tdNodeValue,$urlMatch))
182 $urlUploadName = $this->fromURL($tdNodeValue);
183 $this->getAnchors($node, $urlUploadName);
190 if(!empty($this->anchors))
192 $this->browseList = array_merge($this->browseList, $this->anchors);
193 $this->anchors = array();
197 if(empty($this->browseList)) {
198 $this->noRows = TRUE;
216 $matches = preg_match_all(
"/.*?\[<a href='(.*?)'.*?>([V|I|Down].*?)</", $this->page, $fileMini, PREG_PATTERN_ORDER);
217 print
"fileMini Menus are:";
218 print_r($fileMini) .
"\n";
231 $matches = preg_match_all(
"/.+class='mono'.*?<a href='(.*)'>(.*?)<\/a>/", $this->page, $dirs, PREG_PATTERN_ORDER);
234 return ($this->_createRtnArray($dirs, $matches));
237 function _createRtnArray($array, $matches)
245 $numMenus = count($array[1]);
247 for ($i = 0; $i <= $numMenus -1; $i++)
249 $rtnList[$array[2][$i]] = $array[1][$i];
280 $numMenus = count($array[1]);
281 $loopCnt = $numMenus / 3;
285 for ($i = 0; $i <= $loopCnt -1; $i++)
288 for ($j = 0; $j <= 2; $j++)
290 $triple[$array[2][$j]] = $array[1][$index];
293 $rtnList[$i] = $triple;