Ejemplo n.º 1
0
function PageCodeEdit()
{
    $aForm = array('form_attrs' => array('id' => 'adm-css-edit', 'name' => 'adm-css-edit', 'action' => $GLOBALS['site']['url_admin'] . 'css_file.php', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => '', 'key' => '', 'uri' => '', 'uri_title' => '', 'submit_name' => 'adm-css-save')), 'inputs' => array('css_file' => array('type' => 'select', 'name' => 'css_file', 'caption' => _t('_adm_txt_css_file'), 'value' => '', 'values' => array(), 'attrs' => array('onchange' => "javascript:document.forms['adm-css-edit'].submit();")), 'content' => array('type' => 'textarea', 'name' => 'content', 'caption' => _t('_adm_txt_css_content', $sFileName), 'value' => '', 'db' => array('pass' => 'XssHtml')), 'adm-css-save' => array('type' => 'submit', 'name' => 'adm-css-save', 'value' => _t('_adm_btn_css_save'))));
    //--- Get CSS files ---//
    $aItems = array();
    $sBasePath = BX_DIRECTORY_PATH_ROOT . "templates/tmpl_" . $GLOBALS['oSysTemplate']->getCode() . "/css/";
    $rHandle = opendir($sBasePath);
    while (($sFile = readdir($rHandle)) !== false) {
        if (is_file($sBasePath . $sFile) && substr($sFile, -3) == 'css') {
            $aItems[] = array('key' => $sFile, 'value' => $sFile);
        }
    }
    closedir($rHandle);
    $sCurrentFile = isset($_POST['css_file']) && preg_match("/^\\w+\\.css\$/", $_POST['css_file']) ? $_POST['css_file'] : $aItems[0]['key'];
    $aForm['inputs']['css_file']['value'] = $sCurrentFile;
    $aForm['inputs']['css_file']['values'] = $aItems;
    //--- Get CSS file's content ---//
    $sContent = '';
    $sAbsolutePath = $sBasePath . $sCurrentFile;
    if (strlen($sCurrentFile) > 0 && is_file($sAbsolutePath)) {
        $rHandle = fopen($sAbsolutePath, 'r');
        while (!feof($rHandle)) {
            $sContent .= fgets($rHandle, 4096);
        }
        fclose($rHandle);
    }
    //$aForm['inputs']['content']['value'] = isset($_POST['content']) ? $_POST['content'] : $sContent;
    $aForm['inputs']['content']['value'] = $sContent;
    $oForm = new BxTemplFormView($aForm);
    $oForm->initChecker();
    if ($oForm->isSubmittedAndValid()) {
        if (file_exists($sAbsolutePath) && isRWAccessible($sAbsolutePath)) {
            $rHandle = fopen($sAbsolutePath, 'w');
            if ($rHandle) {
                fwrite($rHandle, clear_xss($_POST['content']));
                fclose($rHandle);
                $mixedResult = '_adm_txt_css_success_save';
            } else {
                $mixedResult = '_adm_txt_css_failed_save';
            }
        } else {
            $mixedResult = '_adm_txt_css_cannot_write';
        }
    }
    $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()));
    if ($mixedResult !== true && !empty($mixedResult)) {
        $sResult = MsgBox(_t($mixedResult, $sCurrentFile), 3) . $sResult;
    }
    return $sResult;
}
Ejemplo n.º 2
0
function PreInstall($errorMessage = '')
{
    global $aConf, $permFiles, $permDirectories, $aRayFolders, $aRayFiles;
    if (ini_get('safe_mode') == 1 || ini_get('safe_mode') == 'On') {
        $errorMessage .= "Please turn off <b>safe_mode</b> in your php.ini file configuration";
    }
    $ret = '';
    $ret .= '<div class="position">Permissions</div>';
    if (strlen($errorMessage)) {
        $ret .= printInstallError($errorMessage);
    }
    $ret .= '<div class="LeftRirght">';
    $ret .= '<div class="clearBoth"></div>';
    $ret .= '<div class="left">
			Dolphin needs special access for certain files and directories. Please, change permissions as 
specified in the chart below. Helpful info about permissions is <a href="http://www.boonex.net/cgi-bin/trac_dolphin.cgi/wiki/DetailedInstall#Permissions" target="_blank">available here</a>.
		</div>';
    $ret .= '<div class="clear_both"></div>';
    $ret .= '<div class="right">
			<table cellpadding="0" cellspacing="1" width="100%" border="0" style="background-color:silver;">
				<tr class="head">
					<td>Directories</td>
					<td>Current Level</td>
					<td>Desired Level</td>
				</tr>';
    $i = 0;
    asort($permDirectories);
    asort($permFiles);
    foreach ($permDirectories as $dir) {
        if ($i % 2 == 0) {
            $styleAdd = 'background-color:#ede9e9;';
        } else {
            $styleAdd = 'background-color:#fff;';
        }
        $ret .= '<tr style="' . $styleAdd . '" class="cont">';
        $ret .= '<td>' . $dir . '</td>';
        $ret .= '<td class="span">';
        if (isFullAccessible('../' . $dir)) {
            $ret .= '<span class="writable">' . getPermissions('../' . $dir) . '</span><span>Writable</span>';
        } else {
            $ret .= '<span class="unwritable">' . getPermissions('../' . $dir) . '</span><span>Non-writable</span>';
        }
        $ret .= '</td>';
        $ret .= '<td class="span">';
        $ret .= '<span class="desired">777</span><span>Writable</span>';
        $ret .= '</td>';
        $ret .= '</tr>';
        $i++;
    }
    $ret .= '<tr class="head">
					<td>Files</td>
					<td>Current Level</td>
					<td>Desired Level</td>
				</tr>
				';
    $i = 0;
    foreach ($permFiles as $file) {
        $str = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'];
        $dir = preg_replace("/install\\/(index\\.php\$)/", "", $str);
        if (file_exists($dir . $file)) {
            if ($i % 2 == 0) {
                $styleAdd = 'background-color:#ede9e9;';
            } else {
                $styleAdd = 'background-color:#fff;';
            }
            $ret .= '<tr style="' . $styleAdd . '" class="cont">';
            $ret .= '<td>' . $file . '</td>';
            $ret .= '<td class="span">';
            if (isRWAccessible('../' . $file)) {
                $ret .= '<span class="writable">' . getPermissions('../' . $file) . '</span><span>Writable</span>';
            } else {
                $ret .= '<span class="unwritable">' . getPermissions('../' . $file) . '</span><span>Non-writable</span>';
            }
            $ret .= '</td>';
            $ret .= '<td class="span">';
            $ret .= '<span class="desired">666</span><span>Writable</span>';
            $ret .= '</td>';
            $ret .= '</tr>';
            $i++;
        }
    }
    $ret .= '<tr class="head">
					<td>Ray Folders</td>
					<td>Current Level</td>
					<td>Desired Level</td>
				</tr>';
    $i = 0;
    foreach ($aRayFolders as $dir) {
        if ($i % 2 == 0) {
            $styleAdd = 'background-color:#ede9e9;';
        } else {
            $styleAdd = 'background-color:#fff;';
        }
        $ret .= '<tr style="' . $styleAdd . '" class="cont">';
        $ret .= '<td>' . $dir . '</td>';
        $ret .= '<td class="span">';
        if (isFullAccessible('../' . $dir)) {
            $ret .= '<span class="writable">' . getPermissions('../' . $dir) . '</span><span>Writable</span>';
        } else {
            $ret .= '<span class="unwritable">' . getPermissions('../' . $dir) . '</span><span>Non-writable</span>';
        }
        $ret .= '</td>';
        $ret .= '<td class="span">';
        $ret .= '<span class="desired">777</span><span>Writable</span>';
        $ret .= '</td>';
        $ret .= '</tr>';
        $i++;
    }
    $ret .= '<tr class="head">
					<td>Ray Files</td>
					<td>Current Level</td>
					<td>Desired Level</td>
				</tr>
				';
    $i = 0;
    foreach ($aRayFiles as $file) {
        $str = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'];
        $dir = preg_replace("/install\\/(index\\.php\$)/", "", $str);
        if (file_exists($dir . $file)) {
            if ($i % 2 == 0) {
                $styleAdd = 'background-color:#ede9e9;';
            } else {
                $styleAdd = 'background-color:#fff;';
            }
            $ret .= '<tr style="' . $styleAdd . '" class="cont">';
            $ret .= '<td>' . $file . '</td>';
            $ret .= '<td class="span">';
            if (strpos($file, 'ffmpeg') === FALSE) {
                if (isRWAccessible('../' . $file)) {
                    $ret .= '<span class="writable">' . getPermissions('../' . $file) . '</span><span>Writable</span>';
                } else {
                    $ret .= '<span class="unwritable">' . getPermissions('../' . $file) . '</span><span>Non-writable</span>';
                }
            } else {
                if (isFullAccessible('../' . $file)) {
                    $ret .= '<span class="writable">' . getPermissions('../' . $file) . '</span><span>Executable</span>';
                } else {
                    $ret .= '<span class="unwritable">' . getPermissions('../' . $file) . '</span><span>Unexecutable</span>';
                    $bError = TRUE;
                }
            }
            $ret .= '</td>';
            $ret .= '<td class="span">';
            if (strpos($file, 'ffmpeg') === FALSE) {
                $ret .= '<span class="desired">666</span><span>Writable</span>';
            } else {
                $ret .= '<span class="desired">777</span><span>Executable</span>';
            }
            $ret .= '</td>';
            $ret .= '</tr>';
            $i++;
        }
    }
    $ret .= '
			</table>
			<div class="formKeeper">
				<div class="button_area_1">
					<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
						<input id="button" type="image" src="images/check.gif" />
						<input type="hidden" name="action" value="preInstall" />
					</form>
				</div>';
    $ret .= '
				<div class="button_area_2">
					<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
						<input id="button" type="image" src="images/next.gif" />
						<input type="hidden" name="action" value="step1" />
					</form>
				</div>
				<div class="clearBoth"></div>
			</div>
		</div>';
    $ret .= '</div>';
    return $ret;
}
Ejemplo n.º 3
0
    $fp = fopen($path . $fname, 'r');
    $content = '';
    if ($fp) {
        while (!feof($fp)) {
            $content .= fgets($fp, 4096);
        }
        fclose($fp);
    }
    ?>
		<br /><br />
		<div style="padding-left: 4px; padding-right: 4px; text-align: left;">
			Editing file <b><?php 
    echo $fname;
    ?>
</b>: <?php 
    echo !isRWAccessible($path . $fname) ? "<span class=\"err\" style=\"margin-left:5px;\">File {$fname} is not writable</span>" : "<span class=\"succ\" style=\"margin-left:5px;\">File {$fname} has write permissions</span>";
    ?>
<br />
			<textarea cols="81" rows="30" name="content" style="font-family: 'Courier New'; font-size: 11px;"><?php 
    echo htmlspecialchars($content);
    ?>
</textarea>
		</div>
		<br />
		<input type="submit" name="save" class="no" value="Save" style="width: 60px" />
<?php 
}
?>
	</form>
</div>
<?php