function deleteDirR($src) { //recursive copy of directory if (substr($src,0,-1)!='/') $src.='/'; $d = dir($src); while($entry=readdir($d->handle)) { if(is_dir($d->path.$entry)) { if(strlen($entry)>2) { deleteDirR($d->path.$entry); } else { if($entry[0]!='.') { deleteDirR($d->path.$entry,$dst.$entry); } else { if(strlen($entry)>1&&$entry[1]!='.') { deleteDirR($d->path.$entry,$dst.$entry); } } } if ($entry!='.' && $entry!='..') { rmdir($d->path.$entry); } } else { unlink($d->path.$entry); } } $d->close(); }
function showBladePacks($type) { if ($_SESSION['adminType'] == 'user') { return; } if (isset($_GET['bladeinfo']) && isset($_GET['blade']) && $_GET['bladeinfo'] == 'show') { $bladeName = stripslashes($_GET['blade']); if (file_exists(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BLADEPACK_DIR . $bladeName . '.xml')) { showBladePackInfo($bladeName . '.xml'); } } global $bladeList, $razorArray; $activeBlades = $razorArray['active-bladepack']; $xmlList = array(); $descTxt = lt('Description'); $optTxt = lt('Options'); // generate list of xml files and get data // $fileList = readDirContents(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BLADEPACK_DIR); foreach ($fileList as $foundFile) { $getFileExt = explode('.', basename($foundFile)); $fileExt = end($getFileExt); if ($fileExt == 'xml') { $xmlData = file_get_contents(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BLADEPACK_DIR . $foundFile); $bpDetails = new BPCONTROL(); if ($bpDetails->getXmlData($xmlData, $foundFile)) { // read xml data and remove file $bpDetails->getBPName(); $bpDetails->getBPVersion(); $bpDetails->getBPDesc(); $bpDetails->getBPAuth(); $bpDetails->getBPClass(); $tempVar = explode('.', basename($foundFile)); $bladeID = reset($tempVar); $xmlList[$bladeID]['title'] = $bpDetails->name; $xmlList[$bladeID]['version'] = $bpDetails->version; $xmlList[$bladeID]['description'] = $bpDetails->description; $xmlList[$bladeID]['author'] = $bpDetails->author; $xmlList[$bladeID]['class'] = $bpDetails->className; } } } // process form data // if (isset($_GET['do'])) { $do = $_GET['do']; $blade = $_GET['blade']; if (in_array($blade, array_keys($xmlList))) { if ($do == 'activate' && !in_array($blade, $activeBlades)) { $activeBlades[] = $blade; echo MsgBox(lt('Blade Pack Activated'), 'greenbox'); $razorArray['active-bladepack'] = $activeBlades; saveRazorArray(); } if ($do == 'deactivate' && in_array($blade, $activeBlades)) { $activeBlades = array_diff($activeBlades, (array) $blade); echo MsgBox(lt('Blade Pack Deactivated'), 'greenbox'); $razorArray['active-bladepack'] = $activeBlades; saveRazorArray(); } if ($do == 'delete' && $blade) { // remove the bladepack permanently if (file_exists(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BLADEPACK_DIR . $blade . '.xml')) { $xmlData = file_get_contents(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BLADEPACK_DIR . $blade . '.xml'); $bpRemove = new BPCONTROL(); if ($bpRemove->getXmlData($xmlData, $blade . '.xml')) { // read xml data and remove file if ($bpRemove->getXMLName() && $bpRemove->getBFName()) { if (deleteFile(RAZOR_BLADEPACK_DIR . $bpRemove->xmlName, false) && deleteFile(RAZOR_BLADEPACK_DIR . $bpRemove->bladepackName, false)) { if ($bpRemove->getDIRName()) { deleteDirR(RAZOR_BLADEPACK_DIR . $bpRemove->folderName); } // remove from active blades // if (in_array($blade, $activeBlades)) { $activeBlades = array_diff($activeBlades, (array) $blade); $razorArray['active-bladepack'] = $activeBlades; saveRazorArray(); } MsgBox(lt('Blade pack removed sucessfully'), 'greenbox'); } else { MsgBox(lt('Remove error, all files could not be deleted'), 'redbox'); } } else { MsgBox(lt('Could not remove bladepack, XML data incorrect'), 'redbox'); } } else { MsgBox(lt('Could not remove bladepack, could not get XML data'), 'redbox'); } } else { MsgBox(lt('Could not remove bladepack, XML file not found'), 'redbox'); } } } } // end // // scrub xml list clean // $xmlList = array(); // re-generate list of xml files and get data // $fileList = readDirContents(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BLADEPACK_DIR); foreach ($fileList as $foundFile) { $getFileExt = explode('.', basename($foundFile)); $fileExt = end($getFileExt); if ($fileExt == 'xml') { $xmlData = file_get_contents(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BLADEPACK_DIR . $foundFile); $bpDetails = new BPCONTROL(); if ($bpDetails->getXmlData($xmlData, $foundFile)) { // read xml data and remove file $bpDetails->getBPName(); $bpDetails->getBPVersion(); $bpDetails->getBPDesc(); $bpDetails->getBPAuth(); $bpDetails->getBPClass(); $tempVar = explode('.', basename($foundFile)); $bladeID = reset($tempVar); $xmlList[$bladeID]['title'] = $bpDetails->name; $xmlList[$bladeID]['version'] = $bpDetails->version; $xmlList[$bladeID]['description'] = $bpDetails->description; $xmlList[$bladeID]['author'] = $bpDetails->author; $xmlList[$bladeID]['class'] = $bpDetails->className; } } } // sort xml data using xml compare function to sort by title // uasort($xmlList, "xmlCmp"); // output text and table for blades installed // $bladeerDescTxt = lt('Blade Packs are sets of blades, each blade can be allocated to a socket to add extra functionality to the base system. The base system is capable of using many blades, even allocating more than one to a single slot. Use the manager to activate and deactivate your blade packs.'); $delConfirmMsg = lt('Are you sure you want to permanently delete the blade pack from the system') . '?'; BsocketB('output-blade-manager'); echo "<h1>" . lt('Installed Blade Packs') . "</h1>"; echo "<div class='contentwh'>"; echo "<h3>" . lt(ucfirst($type)) . "</h3>"; echo "<p>{$bladeerDescTxt}</p>"; $t = "<table class='tableViewBlades'>"; $t .= "<tr class='tableTitle'><th class='twenty'>" . lt('Blade Pack') . "</th><th class='auto'>{$descTxt}</th><th class='ten'>" . lt('Version') . "</th><th class='ten'>" . lt('Author') . "</th><th class='ten'>" . lt('Control') . "</th></tr>"; foreach ($xmlList as $bladeName => $bladeInfo) { if (strtolower($bladeInfo['class']) == $type) { if (in_array($bladeName, $activeBlades)) { $Lable = makeLink("?action=blade{$type}&do=deactivate&blade={$bladeName}", "<img class='deactivate' src='theme/images/subtract.gif' alt='" . lt('Deactivate') . "' />"); } else { $Lable = makeLink("?action=blade{$type}&do=activate&blade={$bladeName}", "<img class='activate' src='theme/images/add.gif' alt='" . lt('Activate') . "' />"); } $desc = $xmlList[$bladeName]['description']; $name = $xmlList[$bladeName]['title']; $version = $xmlList[$bladeName]['version']; $author = $xmlList[$bladeName]['author']; $removePack = makeLink("?action=blade{$type}&do=delete&blade={$bladeName}", "<img class='deactivate' src='theme/images/trash.gif' alt='" . lt('Delete') . "' onclick='return confirm(\"{$delConfirmMsg}\");'/>"); $info = makeLink("?action=blade{$type}&bladeinfo=show&blade={$bladeName}", "<img class='edit' src='theme/images/alert.gif' alt='" . lt('Info') . "'/>"); $t .= "<tr><td>{$name}</td><td>{$desc}</td><td>{$version}</td><td>{$author}</td><td>{$Lable} {$removePack} {$info}</td></tr>"; } } $t .= "<tr class='tableFooter'><th class='twenty'></th><th class='auto'></th><th class='ten'></th><th class='ten'></th><th class='ten'></th></tr></table></div>"; echo $t; // end // }