Example #1
0
ob_start();
///////////////////////////////////////////////////////////
// Load razor data file  //////////////////////////////////
$razorArray = unserialize(file_get_contents(getSystemRoot(RAZOR_HOME_FILENAME) . RAZOR_DATA));
///////////////////////////////////////////////////////////
// Setup headers to set charset ///////////////////////////
$charset = 'ISO-8859-1';
if (isset($razorArray['settings']['charset'])) {
    $charset = $razorArray['settings']['charset'];
}
header("Content-type: text/html; charset={$charset}");
///////////////////////////////////////////////////////////
// load active installed blades ///////////////////////////
foreach ($razorArray['active-bladepack'] as $bladePack) {
    if (file_exists(getSystemRoot(RAZOR_HOME_FILENAME) . RAZOR_BLADEPACK_DIR . $bladePack . '.php')) {
        include_once getSystemRoot(RAZOR_HOME_FILENAME) . RAZOR_BLADEPACK_DIR . $bladePack . '.php';
    }
}
///////////////////////////////////////////////////////////
// edit razor array ///////////////////////////////////////
BsocketB('public-edit-razorarray', array(&$razorArray));
///////////////////////////////////////////////////////////
// set page contents to display ///////////////////////////
$theme = setActivePage();
///////////////////////////////////////////////////////////
// socket load points /////////////////////////////////////
BsocketB('public-index-socket1');
BsocketB('public-index-socket2');
BsocketB('public-index-socket3');
///////////////////////////////////////////////////////////
// end buffering of output ////////////////////////////////
function bladepackInstall()
{
    if ($_SESSION['adminType'] == 'user') {
        return;
    }
    $startInstall = false;
    if (isset($_GET['startinstall']) && $_GET['startinstall']) {
        $startInstall = true;
    }
    if ($startInstall) {
        $filename = basename($_FILES['file-upload']['name']);
        $stripFileName = explode('.', $filename);
        if (end($stripFileName) == 'zip') {
            $bladepacksDir = getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BLADEPACK_DIR;
            $bladepackFiles = readDirContents($bladepacksDir);
            $fileExists = false;
            foreach ($bladepackFiles as $fileCheck) {
                $fileCheckT = explode('.', $fileCheck);
                $filenameT = explode('.', $filename);
                if (reset($fileCheckT) == reset($filenameT)) {
                    $fileExists = true;
                }
            }
            if (!$fileExists) {
                uploadFile(RAZOR_BLADEPACK_DIR . $filename, $_FILES['file-upload']['tmp_name']);
                $bpInstall = new BPCONTROL();
                $bpInstall->extractContents(RAZOR_BLADEPACK_DIR . $filename);
                if ($bpInstall->checkContents(RAZOR_BLADEPACK_DIR)) {
                    if ($bpInstall->extractXmlData()) {
                        $bpInstall->saveContents(RAZOR_BLADEPACK_DIR);
                        MsgBox(lt('Bladepack installed successfully'), 'greenbox');
                        if ($bpInstall->searchXmlArray($bpInstall->xmlContents, 'note')) {
                            MsgBox(lt('PLEASE READ SPECIAL NOTES FOR BLADE PACK'), 'yellowbox');
                            $sentance = '';
                            $noteArray = array();
                            $noteArray = $bpInstall->searchXmlArray($bpInstall->xmlContents, 'note');
                            foreach ($noteArray['child'] as $paras) {
                                $sentance .= '<' . $paras['tag'] . '>' . $paras['value'] . '</' . $paras['tag'] . '>';
                            }
                            MsgBox($sentance, 'yellowbox');
                        }
                        deleteFile(RAZOR_BLADEPACK_DIR . $filename, false);
                    } else {
                        MsgBox(lt('Error installing bladepack, cannot parse xml, attempting to clean up install file'), 'redbox');
                        deleteFile(RAZOR_BLADEPACK_DIR . $filename);
                    }
                } else {
                    MsgBox(lt('Error installing bladepack, unpack error, attempting to clean up install file'), 'redbox');
                    deleteFile(RAZOR_BLADEPACK_DIR . $filename);
                }
            } else {
                MsgBox(lt('Error installing bladepack, bladepack already present'), 'redbox');
            }
        } else {
            MsgBox(lt("Error installing bladepack, only bladepack parcels allowed"), 'redbox');
        }
    }
    echo "<h1>" . lt('Install Blade Packs') . "</h1>";
    echo "<div class='contentwh'>";
    echo "<h3>" . lt('Upload blade pack parcel') . "</h3>";
    echo '<p>' . lt('Please only upload verified blade pack parcel files downloaded from the official razorCMS website. All blade pack parcels are distributed in zip archive format') . '.</p>';
    echo '<form enctype="multipart/form-data" action="?action=bladeinstall&startinstall=true" method="POST">';
    echo "<table class='tableViewBlades'>";
    echo "<tr class='tableFooter'><th class='auto'></th><th class='ten'></th></tr>";
    echo '<tr><td><input name="file-upload" type="file" /></td><td><input id="button" type="submit" value="' . lt('upload file') . '" name="upload"/></td></tr>';
    echo "<tr class='tableFooter'><th class='twentyFive'></th><th class='auto'></th></tr></table></form></div>";
}
function findPageFile($name, $locFlag = '')
{
    global $razorArray;
    $pages_Dir = '';
    if ($locFlag == 'admin') {
        $pages_Dir = getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_PAGES_DIR;
    } elseif ($locFlag == 'home') {
        $pages_Dir = getSystemRoot(RAZOR_HOME_FILENAME) . RAZOR_PAGES_DIR;
    }
    if (file_exists($pages_Dir . "{$name}." . RAZOR_DEFAULT_FILE_EXT)) {
        return $pages_Dir . "{$name}." . RAZOR_DEFAULT_FILE_EXT;
    }
    $ext = explode(',', RAZOR_EXTENSIONS_ORDER);
    foreach ($ext as $ex) {
        if (file_exists($pages_Dir . "{$name}.{$ex}")) {
            return $pages_Dir . "{$name}.{$ex}";
        }
    }
    return $pages_Dir . "{$name}." . RAZOR_DEFAULT_FILE_EXT;
}