relative+cleaned paths

This commit is contained in:
stronk7
2006-08-29 20:50:44 +00:00
parent 5e0ff187c7
commit c080aa88d7
4 changed files with 16 additions and 16 deletions
@@ -65,8 +65,8 @@ class create_xml_file extends XMLDBAction {
/// Do the job, setting result as needed
/// Get the dir containing the file
$dirpath = required_param('dir', PARAM_CLEAN);
$dirpath = stripslashes_safe($dirpath);
$dirpath = required_param('dir', PARAM_PATH);
$dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
$file = $dirpath . '/install.xml';
/// Some variables
@@ -64,7 +64,7 @@ class delete_xml_file extends XMLDBAction {
/// Get the dir containing the file
$dirpath = required_param('dir', PARAM_CLEAN);
$dirpath = stripslashes_safe($dirpath);
$dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
$confirmed = optional_param('confirmed', false, PARAM_BOOL);
@@ -72,10 +72,10 @@ class delete_xml_file extends XMLDBAction {
if (!$confirmed) {
$o = '<table align="center" width="60" class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">';
$o.= ' <tr><td class="generalboxcontent">';
$o.= ' <p align="center">' . $this->str['confirmdeletexmlfile'] . '<br /><br />' . $dirpath . '</p>';
$o.= ' <p align="center">' . $this->str['confirmdeletexmlfile'] . '<br /><br />' . $dirpath . '/install.php</p>';
$o.= ' <table align="center" cellpadding="20"><tr><td>';
$o.= ' <div class="singlebutton">';
$o.= ' <form action="index.php?action=delete_xml_file&amp;confirmed=yes&amp;dir=' . urlencode($dirpath) . '&amp;postaction=main_view#lastused" method="post">';
$o.= ' <form action="index.php?action=delete_xml_file&amp;confirmed=yes&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;postaction=main_view#lastused" method="post">';
$o.= ' <input type="submit" value="'. $this->str['yes'] .'" /></form></div>';
$o.= ' </td><td>';
$o.= ' <div class="singlebutton">';
@@ -65,8 +65,8 @@ class load_xml_file extends XMLDBAction {
/// Do the job, setting $result as needed
/// Get the dir containing the file
$dirpath = required_param('dir', PARAM_CLEAN);
$dirpath = stripslashes_safe($dirpath);
$dirpath = required_param('dir', PARAM_PATH);
$dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
/// Get the correct dir
if (!empty($XMLDB->dbdirs)) {
@@ -96,7 +96,7 @@ class main_view extends XMLDBAction {
foreach ($XMLDB->dbdirs as $key => $dbdir) {
/// Detect if this is the lastused dir
$hithis = false;
if ($key == $lastused) {
if (str_replace($CFG->dirroot, '', $key) == $lastused) {
$hithis = true;
}
$elementtext = str_replace($CFG->dirroot . '/', '', $key);
@@ -120,7 +120,7 @@ class main_view extends XMLDBAction {
if ($dbdir->path_exists &&
!file_exists($key . '/install.xml') &&
is_writeable($key)) {
$b .= '<a href="index.php?action=create_xml_file&amp;dir=' . urlencode($key) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['create'] . ']</a>';
$b .= '<a href="index.php?action=create_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['create'] . ']</a>';
} else {
$b .= '[' . $this->str['create'] . ']';
}
@@ -130,7 +130,7 @@ class main_view extends XMLDBAction {
file_exists($key . '/install.xml') &&
is_readable($key . '/install.xml') &&
empty($dbdir->xml_loaded)) {
$b .= '<a href="index.php?action=load_xml_file&amp;dir=' . urlencode($key) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['load'] . ']</a>';
$b .= '<a href="index.php?action=load_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['load'] . ']</a>';
} else {
$b .= '[' . $this->str['load'] . ']';
}
@@ -141,7 +141,7 @@ class main_view extends XMLDBAction {
is_readable($key . '/install.xml') &&
is_readable($key) &&
!empty($dbdir->xml_loaded)) {
$b .= '<a href="index.php?action=edit_xml_file&amp;dir=' . urlencode($key) . '">[' . $this->str['edit'] . ']</a>';
$b .= '<a href="index.php?action=edit_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '">[' . $this->str['edit'] . ']</a>';
} else {
$b .= '[' . $this->str['edit'] . ']';
}
@@ -153,7 +153,7 @@ class main_view extends XMLDBAction {
is_writeable($key) &&
!empty($dbdir->xml_loaded) &&
!empty($dbdir->xml_changed)) {
$b .= '<a href="index.php?action=save_xml_file&amp;dir=' . urlencode($key) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['save'] . ']</a>';
$b .= '<a href="index.php?action=save_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['save'] . ']</a>';
} else {
$b .= '[' . $this->str['save'] . ']';
}
@@ -165,7 +165,7 @@ class main_view extends XMLDBAction {
is_writeable($key) &&
!empty($dbdir->xml_loaded) &&
!empty($dbdir->xml_changed)) {
$b .= '<a href="index.php?action=revert_changes&amp;dir=' . urlencode($key) . '">[' . $this->str['revert'] . ']</a>';
$b .= '<a href="index.php?action=revert_changes&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '">[' . $this->str['revert'] . ']</a>';
} else {
$b .= '[' . $this->str['revert'] . ']';
}
@@ -176,7 +176,7 @@ class main_view extends XMLDBAction {
is_readable($key . '/install.xml') &&
!empty($dbdir->xml_loaded) &&
empty($dbdir->xml_changed)) {
$b .= '<a href="index.php?action=unload_xml_file&amp;dir=' . urlencode($key) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['unload'] . ']</a>';
$b .= '<a href="index.php?action=unload_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['unload'] . ']</a>';
} else {
$b .= '[' . $this->str['unload'] . ']';
}
@@ -187,7 +187,7 @@ class main_view extends XMLDBAction {
is_readable($key . '/install.xml') &&
is_writeable($key) &&
empty($dbdir->xml_loaded)) {
$b .= '<a href="index.php?action=delete_xml_file&amp;dir=' . urlencode($key) . '">[' . $this->str['delete'] . ']</a>';
$b .= '<a href="index.php?action=delete_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '">[' . $this->str['delete'] . ']</a>';
} else {
$b .= '[' . $this->str['delete'] . ']';
}
@@ -196,7 +196,7 @@ class main_view extends XMLDBAction {
if ($dbdir->path_exists &&
file_exists($key . '/install.xml') &&
is_readable($key . '/install.xml')) {
$elementtext = '<a href="index.php?action=view_xml&amp;file=' . urlencode($key . '/install.xml') . '" target="_blank">' . $elementtext . '</a></td>';
$elementtext = '<a href="index.php?action=view_xml&amp;file=' . urlencode(str_replace($CFG->dirroot, '', $key) . '/install.xml') . '" target="_blank">' . $elementtext . '</a></td>';
} else {
$elementtext = $elementtext . '</td>';
}