예제 #1
0
/**
 * Show the technicolor permissions screen that can be adjusted with FTP
 */
function template_file_permissions()
{
    global $txt, $scripturl, $context, $settings;
    // This will handle expanding the selection.
    // @todo most of this code should go in to admin.js
    echo '
	<script><!-- // --><![CDATA[
		var oRadioColors = {
			0: "#D1F7BF",
			1: "#FFBBBB",
			2: "#FDD7AF",
			3: "#C2C6C0",
			4: "#EEEEEE"
		}
		var oRadioValues = {
			0: "read",
			1: "writable",
			2: "execute",
			3: "custom",
			4: "no_change"
		}

		function dynamicAddMore()
		{
			ajax_indicator(true);

			getXMLDocument(elk_prepareScriptUrl(elk_scripturl) + \'action=admin;area=packages;fileoffset=\' + (parseInt(this.offset) + ', $context['file_limit'], ') + \';onlyfind=\' + escape(this.path) + \';sa=perms;xml;', $context['session_var'], '=', $context['session_id'], '\', onNewFolderReceived);
		}

		// Getting something back?
		function onNewFolderReceived(oXMLDoc)
		{
			ajax_indicator(false);

			var fileItems = oXMLDoc.getElementsByTagName(\'folders\')[0].getElementsByTagName(\'folder\');

			// No folders, no longer worth going further.
			if (fileItems.length < 1)
			{
				if (oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0])
				{
					var rootName = oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0].firstChild.nodeValue;
					var itemLink = document.getElementById(\'link_\' + rootName);

					// Move the children up.
					for (i = 0; i <= itemLink.childNodes.length; i++)
						itemLink.parentNode.insertBefore(itemLink.childNodes[0], itemLink);

					// And remove the link.
					itemLink.parentNode.removeChild(itemLink);
				}
				return false;
			}
			var tableHandle = false,
				isMore = false,
				ident = "",
				my_ident = "",
				curLevel = 0;

			for (var i = 0; i < fileItems.length; i++)
			{
				if (fileItems[i].getAttribute(\'more\') == 1)
				{
					isMore = true;
					var curOffset = fileItems[i].getAttribute(\'offset\');
				}

				if (fileItems[i].getAttribute(\'more\') != 1 && document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\')))
				{
					ident = fileItems[i].getAttribute(\'ident\');
					my_ident = fileItems[i].getAttribute(\'my_ident\');
					curLevel = fileItems[i].getAttribute(\'level\') * 5;
					curPath = fileItems[i].getAttribute(\'path\');

					// Get where we\'re putting it next to.
					tableHandle = document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\'));

					var curRow = document.createElement("tr");
					curRow.className = "windowbg";
					curRow.id = "content_" + my_ident;
					curRow.style.display = "";

					var curCol = document.createElement("td");
					curCol.className = "smalltext";
					curCol.width = "40%";

					// This is the name.
					var fileName = document.createTextNode(fileItems[i].firstChild.nodeValue);

					// Start by wacking in the spaces.
					curCol.innerHTML = php_str_repeat("&nbsp;", curLevel);

					// Create the actual text.
					if (fileItems[i].getAttribute(\'folder\') == 1)
					{
						var linkData = document.createElement("a");
						linkData.name = "fol_" + my_ident;
						linkData.id = "link_" + my_ident;
						linkData.href = \'#\';
						linkData.path = curPath + "/" + fileItems[i].firstChild.nodeValue;
						linkData.ident = my_ident;
						linkData.onclick = dynamicExpandFolder;

						var folderImage = document.createElement("img");
						folderImage.src = \'', addcslashes($settings['default_images_url'], "\\"), '/board.png\';
						linkData.appendChild(folderImage);

						linkData.appendChild(fileName);
						curCol.appendChild(linkData);
					}
					else
						curCol.appendChild(fileName);

					curRow.appendChild(curCol);

					// Right, the permissions.
					curCol = document.createElement("td");
					curCol.className = "smalltext";

					var writeSpan = document.createElement("span");
					writeSpan.style.color = fileItems[i].getAttribute(\'writable\') ? "green" : "red";
					writeSpan.innerHTML = fileItems[i].getAttribute(\'writable\') ? \'', $txt['package_file_perms_writable'], '\' : \'', $txt['package_file_perms_not_writable'], '\';
					curCol.appendChild(writeSpan);

					if (fileItems[i].getAttribute(\'permissions\'))
					{
						var permData = document.createTextNode("\\u00a0(', $txt['package_file_perms_chmod'], ': " + fileItems[i].getAttribute(\'permissions\') + ")");
						curCol.appendChild(permData);
					}

					curRow.appendChild(curCol);

					// Now add the five radio buttons.
					for (j = 0; j < 5; j++)
					{
						curCol = document.createElement("td");
						curCol.style.backgroundColor = oRadioColors[j];
						curCol.align = "center";

						var curInput = document.createElement("input");
						curInput.name = "permStatus[" + curPath + "/" + fileItems[i].firstChild.nodeValue + "]";
						curInput.type = "radio";
						curInput.checked = (j == 4 ? "checked" : "");
						curInput.value = oRadioValues[j];

						curCol.appendChild(curInput);
						curRow.appendChild(curCol);
					}

					// Put the row in.
					tableHandle.parentNode.insertBefore(curRow, tableHandle);

					// Put in a new dummy section?
					if (fileItems[i].getAttribute(\'folder\') == 1)
					{
						var newRow = document.createElement("tr");
						newRow.id = "insert_div_loc_" + my_ident;
						newRow.style.display = "none";
						tableHandle.parentNode.insertBefore(newRow, tableHandle);

						var newCol = document.createElement("td");
						newCol.colspan = 2;
						newRow.appendChild(newCol);
					}
				}
			}

			// Is there some more to remove?
			if (document.getElementById("content_" + ident + "_more"))
			{
				document.getElementById("content_" + ident + "_more").parentNode.removeChild(document.getElementById("content_" + ident + "_more"));
			}

			// Add more?
			if (isMore && tableHandle)
			{
				// Create the actual link.
				var linkData = document.createElement("a");
				linkData.href = \'#fol_\' + my_ident;
				linkData.path = curPath;
				linkData.offset = curOffset;
				linkData.onclick = dynamicAddMore;

				linkData.appendChild(document.createTextNode(\'', $txt['package_file_perms_more_files'], '\'));

				curRow = document.createElement("tr");
				curRow.className = "windowbg";
				curRow.id = "content_" + ident + "_more";
				tableHandle.parentNode.insertBefore(curRow, tableHandle);
				curCol = document.createElement("td");
				curCol.className = "smalltext";
				curCol.width = "40%";

				curCol.innerHTML = php_str_repeat("&nbsp;", curLevel);
				curCol.appendChild(document.createTextNode(\'\\u00ab \'));
				curCol.appendChild(linkData);
				curCol.appendChild(document.createTextNode(\' \\u00bb\'));

				curRow.appendChild(curCol);
				curCol = document.createElement("td");
				curCol.className = "smalltext";
				curRow.appendChild(curCol);
			}

			// Keep track of it.
			var curInput = document.createElement("input");
			curInput.name = "back_look[]";
			curInput.type = "hidden";
			curInput.value = curPath;

			curCol.appendChild(curInput);
		}
	// ]]></script>';
    echo '
	<div class="warningbox">
		<div>
			<strong>', $txt['package_file_perms_warning'], ':</strong><br />
				', $txt['package_file_perms_warning_desc'], '
		</div>
	</div>

	<form id="admin_form_wrapper" class="file_permissions" action="', $scripturl, '?action=admin;area=packages;sa=perms;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="UTF-8">
		<h2 class="category_header">
			<span class="floatleft">', $txt['package_file_perms'], '</span><span class="fperm floatright">', $txt['package_file_perms_new_status'], '</span>
		</h2>
		<table class="table_grid">
			<thead>
				<tr class="table_head">
					<th class="lefttext grid30">&nbsp;', $txt['package_file_perms_name'], '&nbsp;</th>
					<th class="lefttext grid30">', $txt['package_file_perms_status'], '</th>
					<th class="centertext grid8"><span class="filepermissions">', $txt['package_file_perms_status_read'], '</span></th>
					<th class="centertext grid8"><span class="filepermissions">', $txt['package_file_perms_status_write'], '</span></th>
					<th class="centertext grid8"><span class="filepermissions">', $txt['package_file_perms_status_execute'], '</span></th>
					<th class="centertext grid8"><span class="filepermissions">', $txt['package_file_perms_status_custom'], '</span></th>
					<th class="centertext grid8"><span class="filepermissions">', $txt['package_file_perms_status_no_change'], '</span></th>
				</tr>
			</thead>
			<tbody>';
    foreach ($context['file_tree'] as $name => $dir) {
        echo '
				<tr class="windowbg2">
					<td class="grid30"><strong>';
        if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
            echo '
						<img src="', $settings['default_images_url'], '/board.png" alt="*" />';
        }
        echo '
						', $name, '</strong>
					</td>
					<td class="grid30">
						<span style="color: ', $dir['perms']['chmod'] ? 'green' : 'red', '">', $dir['perms']['chmod'] ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable'], '</span>
						', $dir['perms']['perms'] ? '&nbsp;(' . $txt['package_file_perms_chmod'] . ': ' . substr(sprintf('%o', $dir['perms']['perms']), -4) . ')' : '', '
					</td>
					<td class="perm_read centertext grid8"><input type="radio" name="permStatus[', $name, ']" value="read" class="input_radio" /></td>
					<td class="perm_write centertext grid8"><input type="radio" name="permStatus[', $name, ']" value="writable" class="input_radio" /></td>
					<td class="perm_execute centertext grid8"><input type="radio" name="permStatus[', $name, ']" value="execute" class="input_radio" /></td>
					<td class="perm_custom centertext grid8"><input type="radio" name="permStatus[', $name, ']" value="custom" class="input_radio" /></td>
					<td class="perm_nochange centertext grid8"><input type="radio" name="permStatus[', $name, ']" value="no_change" checked="checked" class="input_radio" /></td>
				</tr>
			';
        if (!empty($dir['contents'])) {
            template_permission_show_contents($name, $dir['contents'], 1);
        }
    }
    echo '
			</tbody>
		</table>
		<br />
		<h3 class="category_header">', $txt['package_file_perms_change'], '</h3>
		<div class="windowbg">
			<div class="content">
				<fieldset>
					<dl>
						<dt>
							<input type="radio" name="method" value="individual" checked="checked" id="method_individual" class="input_radio" />
							<label for="method_individual"><strong>', $txt['package_file_perms_apply'], '</strong></label>
						</dt>
						<dd>
							<em class="smalltext">', $txt['package_file_perms_custom'], ': <input type="text" name="custom_value" value="0755" maxlength="4" size="5" class="input_text" />&nbsp;<a href="', $scripturl, '?action=quickhelp;help=chmod_flags" onclick="return reqOverlayDiv(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.png" alt="(?)" /></a></em>
						</dd>
						<dt>
							<input type="radio" name="method" value="predefined" id="method_predefined" class="input_radio" />
							<label for="method_predefined"><strong>', $txt['package_file_perms_predefined'], ':</strong></label>
							<select name="predefined" onchange="document.getElementById(\'method_predefined\').checked = \'checked\';">
								<option value="restricted" selected="selected">', $txt['package_file_perms_pre_restricted'], '</option>
								<option value="standard">', $txt['package_file_perms_pre_standard'], '</option>
								<option value="free">', $txt['package_file_perms_pre_free'], '</option>
							</select>
						</dt>
						<dd>
							<em class="smalltext">', $txt['package_file_perms_predefined_note'], '</em>
						</dd>
					</dl>
				</fieldset>';
    // Likely to need FTP?
    if (empty($context['ftp_connected'])) {
        echo '
				<p>
					', $txt['package_file_perms_ftp_details'], ':
				</p>
				', template_control_chmod(), '
				<div class="information">', $txt['package_file_perms_ftp_retain'], '</div>';
    }
    echo '
				<span id="test_ftp_placeholder_full" class="submitbutton"></span>
				<input type="hidden" name="action_changes" value="1" />
				<input type="submit" value="', $txt['package_file_perms_go'], '" name="go" class="right_submit" />
			</div>
		</div>';
    // Any looks fors we've already done?
    foreach ($context['look_for'] as $path) {
        echo '
			<input type="hidden" name="back_look[]" value="', $path, '" />';
    }
    echo '
	</form>';
}
예제 #2
0
function template_file_permissions()
{
    global $txt, $scripturl, $context, $settings;
    // This will handle expanding the selection.
    echo '
	<script type="text/javascript"><!-- // --><![CDATA[
		var oRadioColors = {
			0: "#D1F7BF",
			1: "#FFBBBB",
			2: "#FDD7AF",
			3: "#C2C6C0",
			4: "#EEEEEE"
		}
		var oRadioValues = {
			0: "read",
			1: "writable",
			2: "execute",
			3: "custom",
			4: "no_change"
		}
		function expandFolder(folderIdent, folderReal)
		{
			// See if it already exists.
			var possibleTags = document.getElementsByTagName("tr");
			var foundOne = false;

			for (var i = 0; i < possibleTags.length; i++)
			{
				if (possibleTags[i].id.indexOf("content_" + folderIdent + ":-:") == 0)
				{
					possibleTags[i].style.display = possibleTags[i].style.display == "none" ? "" : "none";
					foundOne = true;
				}
			}

			// Got something then we\'re done.
			if (foundOne)
			{
				return false;
			}
			// Otherwise we need to get the wicked thing.
			else if (window.XMLHttpRequest)
			{
				setBusy(true);
				getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=admin;area=packages;onlyfind=\' + escape(folderReal) + \';sa=perms;xml;', $context['session_var'], '=', $context['session_id'], '\', onNewFolderReceived);
			}
			// Otherwise reload.
			else
				return true;

			return false;
		}
		function dynamicExpandFolder()
		{
			expandFolder(this.ident, this.path);

			return false;
		}
		function dynamicAddMore()
		{
			setBusy(true);

			getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=admin;area=packages;fileoffset=\' + (parseInt(this.offset) + ', $context['file_limit'], ') + \';onlyfind=\' + escape(this.path) + \';sa=perms;xml;', $context['session_var'], '=', $context['session_id'], '\', onNewFolderReceived);
		}
		function repeatString(sString, iTime)
		{
			if (iTime < 1)
				return \'\';
			else
				return sString + repeatString(sString, iTime - 1);
		}
		// Create a named element dynamically - thanks to: http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/
		function createNamedElement(type, name, customFields)
		{
			var element = null;

			if (!customFields)
				customFields = "";

			// Try the IE way; this fails on standards-compliant browsers
			try
			{
				element = document.createElement("<" + type + \' name="\' + name + \'" \' + customFields + ">");
			}
			catch (e)
			{
			}
			if (!element || element.nodeName != type.toUpperCase())
			{
				// Non-IE browser; use canonical method to create named element
				element = document.createElement(type);
				element.name = name;
			}

			return element;
		}
		// Getting something back?
		function onNewFolderReceived(oXMLDoc)
		{
			setBusy(false);

			var fileItems = oXMLDoc.getElementsByTagName(\'folders\')[0].getElementsByTagName(\'folder\');

			// No folders, no longer worth going further.
			if (fileItems.length < 1)
			{
				if (oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0])
				{
					var rootName = oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0].firstChild.nodeValue;
					var itemLink = document.getElementById(\'link_\' + rootName);

					// Move the children up.
					for (i = 0; i <= itemLink.childNodes.length; i++)
						itemLink.parentNode.insertBefore(itemLink.childNodes[0], itemLink);

					// And remove the link.
					itemLink.parentNode.removeChild(itemLink);
				}
				return false;
			}
			var tableHandle = false;
			var isMore = false;
			var ident = "";
			var my_ident = "";
			var curLevel = 0;

			for (var i = 0; i < fileItems.length; i++)
			{
				if (fileItems[i].getAttribute(\'more\') == 1)
				{
					isMore = true;
					var curOffset = fileItems[i].getAttribute(\'offset\');
				}

				if (fileItems[i].getAttribute(\'more\') != 1 && document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\')))
				{
					ident = fileItems[i].getAttribute(\'ident\');
					my_ident = fileItems[i].getAttribute(\'my_ident\');
					curLevel = fileItems[i].getAttribute(\'level\') * 5;
					curPath = fileItems[i].getAttribute(\'path\');

					// Get where we\'re putting it next to.
					tableHandle = document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\'));

					var curRow = document.createElement("tr");
					curRow.className = "windowbg";
					curRow.id = "content_" + my_ident;
					curRow.style.display = "";
					var curCol = document.createElement("td");
					curCol.className = "smalltext";
					curCol.width = "40%";

					// This is the name.
					var fileName = document.createTextNode(fileItems[i].firstChild.nodeValue);

					// Start by wacking in the spaces.
					setInnerHTML(curCol, repeatString("&nbsp;", curLevel));

					// Create the actual text.
					if (fileItems[i].getAttribute(\'folder\') == 1)
					{
						var linkData = document.createElement("a");
						linkData.name = "fol_" + my_ident;
						linkData.id = "link_" + my_ident;
						linkData.href = \'#\';
						linkData.path = curPath + "/" + fileItems[i].firstChild.nodeValue;
						linkData.ident = my_ident;
						linkData.onclick = dynamicExpandFolder;

						var folderImage = document.createElement("img");
						folderImage.src = \'', addcslashes($settings['default_images_url'], "\\"), '/board.gif\';
						linkData.appendChild(folderImage);

						linkData.appendChild(fileName);
						curCol.appendChild(linkData);
					}
					else
						curCol.appendChild(fileName);

					curRow.appendChild(curCol);

					// Right, the permissions.
					curCol = document.createElement("td");
					curCol.className = "smalltext";

					var writeSpan = document.createElement("span");
					writeSpan.style.color = fileItems[i].getAttribute(\'writable\') ? "green" : "red";
					setInnerHTML(writeSpan, fileItems[i].getAttribute(\'writable\') ? \'', $txt['package_file_perms_writable'], '\' : \'', $txt['package_file_perms_not_writable'], '\');
					curCol.appendChild(writeSpan);

					if (fileItems[i].getAttribute(\'permissions\'))
					{
						var permData = document.createTextNode("\\u00a0(', $txt['package_file_perms_chmod'], ': " + fileItems[i].getAttribute(\'permissions\') + ")");
						curCol.appendChild(permData);
					}

					curRow.appendChild(curCol);

					// Now add the five radio buttons.
					for (j = 0; j < 5; j++)
					{
						curCol = document.createElement("td");
						curCol.style.backgroundColor = oRadioColors[j];
						curCol.align = "center";

						var curInput = createNamedElement("input", "permStatus[" + curPath + "/" + fileItems[i].firstChild.nodeValue + "]", j == 4 ? \'checked="checked"\' : "");
						curInput.type = "radio";
						curInput.checked = "checked";
						curInput.value = oRadioValues[j];

						curCol.appendChild(curInput);
						curRow.appendChild(curCol);
					}

					// Put the row in.
					tableHandle.parentNode.insertBefore(curRow, tableHandle);

					// Put in a new dummy section?
					if (fileItems[i].getAttribute(\'folder\') == 1)
					{
						var newRow = document.createElement("tr");
						newRow.id = "insert_div_loc_" + my_ident;
						newRow.style.display = "none";
						tableHandle.parentNode.insertBefore(newRow, tableHandle);
						var newCol = document.createElement("td");
						newCol.colspan = 2;
						newRow.appendChild(newCol);
					}
				}
			}

			// Is there some more to remove?
			if (document.getElementById("content_" + ident + "_more"))
			{
				document.getElementById("content_" + ident + "_more").parentNode.removeChild(document.getElementById("content_" + ident + "_more"));
			}

			// Add more?
			if (isMore && tableHandle)
			{
				// Create the actual link.
				var linkData = document.createElement("a");
				linkData.href = \'#fol_\' + my_ident;
				linkData.path = curPath;
				linkData.offset = curOffset;
				linkData.onclick = dynamicAddMore;

				linkData.appendChild(document.createTextNode(\'', $txt['package_file_perms_more_files'], '\'));

				curRow = document.createElement("tr");
				curRow.className = "windowbg";
				curRow.id = "content_" + ident + "_more";
				tableHandle.parentNode.insertBefore(curRow, tableHandle);
				curCol = document.createElement("td");
				curCol.className = "smalltext";
				curCol.width = "40%";

				setInnerHTML(curCol, repeatString("&nbsp;", curLevel));
				curCol.appendChild(document.createTextNode(\'\\u00ab \'));
				curCol.appendChild(linkData);
				curCol.appendChild(document.createTextNode(\' \\u00bb\'));

				curRow.appendChild(curCol);
				curCol = document.createElement("td");
				curCol.className = "smalltext";
				curRow.appendChild(curCol);
			}

			// Keep track of it.
			var curInput = createNamedElement("input", "back_look[]");
			curInput.type = "hidden";
			curInput.value = curPath;

			curCol.appendChild(curInput);
		}
	// ]]></script>';
    echo '
	<div class="information">
		<div>
			<strong>', $txt['package_file_perms_warning'], ':</strong>
			<div class="smalltext">
				<ol style="margin-top: 2px; margin-bottom: 2px">
					', $txt['package_file_perms_warning_desc'], '
				</ol>
			</div>
		</div>
	</div>

	<form action="', $scripturl, '?action=admin;area=packages;sa=perms;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="UTF-8">
		<div class="cat_bar">
			<h3>
				<span class="floatleft">', $txt['package_file_perms'], '</span><span class="fperm floatright">', $txt['package_file_perms_new_status'], '</span>
			</h3>
		</div>
		<table style="width:100%;" class="table_grid">
			<thead>
				<tr>
					<th class="red_container first_th lefttext" style="width:30%;">&nbsp;', $txt['package_file_perms_name'], '&nbsp;</th>
					<th class="red_container lefttext" style="width:30%;">', $txt['package_file_perms_status'], '</th>
					<th class="red_container centertext" style="width:8%;"><span class="filepermissions">', $txt['package_file_perms_status_read'], '</span></th>
					<th class="red_container centertext" style="width:8%;"><span class="filepermissions">', $txt['package_file_perms_status_write'], '</span></th>
					<th class="red_container centertext" style="width:8%;"><span class="filepermissions">', $txt['package_file_perms_status_execute'], '</span></th>
					<th class="red_container centertext" style="width:8%;"><span class="filepermissions">', $txt['package_file_perms_status_custom'], '</span></th>
					<th class="red_container last_th centertext" style="width:8%;"><span class="filepermissions">', $txt['package_file_perms_status_no_change'], '</span></th>
				</tr>
			</thead>';
    foreach ($context['file_tree'] as $name => $dir) {
        echo '
			<tbody>
				<tr class="windowbg2">
					<td width="30%"><strong>';
        if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
            echo '
						<img src="', $settings['default_images_url'], '/board.gif" alt="*" />';
        }
        echo '
						', $name, '
					</strong></td>
					<td width="30%">
						<span style="color: ', $dir['perms']['chmod'] ? 'green' : 'red', '">', $dir['perms']['chmod'] ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable'], '</span>
						', $dir['perms']['perms'] ? '&nbsp;(' . $txt['package_file_perms_chmod'] . ': ' . substr(sprintf('%o', $dir['perms']['perms']), -4) . ')' : '', '
					</td>
					<td align="center" class="perm_read" width="8%"><input type="radio" name="permStatus[', $name, ']" value="read" class="input_radio" /></td>
					<td align="center" class="perm_write" width="8%"><input type="radio" name="permStatus[', $name, ']" value="writable" class="input_radio" /></td>
					<td align="center" class="perm_execute" width="8%"><input type="radio" name="permStatus[', $name, ']" value="execute" class="input_radio" /></td>
					<td align="center" class="perm_custom" width="8%"><input type="radio" name="permStatus[', $name, ']" value="custom" class="input_radio" /></td>
					<td align="center" class="perm_nochange" width="8%"><input type="radio" name="permStatus[', $name, ']" value="no_change" checked="checked" class="input_radio" /></td>
				</tr>
			</tbody>';
        if (!empty($dir['contents'])) {
            template_permission_show_contents($name, $dir['contents'], 1);
        }
    }
    echo '

		</table>
		<br />
		<div class="cat_bar">
			<h3>', $txt['package_file_perms_change'], '</h3>
		</div>
		<div class="blue_container">
			<div class="content">
				<fieldset>
					<dl>
						<dt>
							<input type="radio" name="method" value="individual" checked="checked" id="method_individual" class="input_radio" />
							<label for="method_individual"><strong>', $txt['package_file_perms_apply'], '</strong></label>
						</dt>
						<dd>
							<em class="smalltext">', $txt['package_file_perms_custom'], ': <input type="text" name="custom_value" value="0755" maxlength="4" size="5" class="input_text" />&nbsp;<a href="', $scripturl, '?action=helpadmin;help=chmod_flags" onclick="return reqWin(this.href);" class="help">(?)</a></em>
						</dd>
						<dt>
							<input type="radio" name="method" value="predefined" id="method_predefined" class="input_radio" />
							<label for="method_predefined"><strong>', $txt['package_file_perms_predefined'], ':</strong></label>
							<select name="predefined" onchange="document.getElementById(\'method_predefined\').checked = \'checked\';">
								<option value="restricted" selected="selected">', $txt['package_file_perms_pre_restricted'], '</option>
								<option value="standard">', $txt['package_file_perms_pre_standard'], '</option>
								<option value="free">', $txt['package_file_perms_pre_free'], '</option>
							</select>
						</dt>
						<dd>
							<em class="smalltext">', $txt['package_file_perms_predefined_note'], '</em>
						</dd>
					</dl>
				</fieldset>';
    // Likely to need FTP?
    if (empty($context['ftp_connected'])) {
        echo '
				<p>
					', $txt['package_file_perms_ftp_details'], ':
				</p>
				', template_control_chmod(), '
				<div class="information">', $txt['package_file_perms_ftp_retain'], '</div>';
    }
    echo '
				<span id="test_ftp_placeholder_full"></span>
				<div class="righttext padding">
					<input type="hidden" name="action_changes" value="1" />
					<input type="submit" value="', $txt['package_file_perms_go'], '" name="go" class="button_submit" />
				</div>
			</div>
		</div>';
    // Any looks fors we've already done?
    foreach ($context['look_for'] as $path) {
        echo '
			<input type="hidden" name="back_look[]" value="', $path, '" />';
    }
    echo '
	</form><br />';
}
/**
 * Template for the database maintenance tasks.
 */
function template_maintain_database()
{
    global $context, $settings, $txt, $scripturl;
    // If maintenance has finished tell the user.
    if (!empty($context['maintenance_finished'])) {
        echo '
			<div class="successbox">
				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
			</div>';
    }
    echo '
	<div id="manage_maintenance">
		<h2 class="category_header">', $txt['maintain_optimize'], '</h2>
		<div class="windowbg">
			<div class="content">
				<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=optimize" method="post" accept-charset="UTF-8">
					<p>', $txt['maintain_optimize_info'], '</p>
					<div class="submitbutton">
						<input type="submit" value="', $txt['maintain_run_now'], '" class="button_submit" />
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
						<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '" />
					</div>
				</form>
			</div>
		</div>
		<h3 class="category_header">
			<a href="', $scripturl, '?action=quickhelp;help=maintenance_backup" onclick="return reqOverlayDiv(this.href);" class="help">
				<img src="', $settings['images_url'], '/helptopics.png" class="icon" alt="', $txt['help'], '" />
			</a> ', $txt['maintain_backup'], '
		</h3>
		<div class="windowbg">
			<div class="content">
				<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=backup" method="post" accept-charset="UTF-8">
					<p>', $txt['maintain_backup_info'], '</p>';
    if ($context['safe_mode_enable']) {
        echo '
				<div class="errorbox">', $txt['safe_mode_enabled'], '</div>';
    } else {
        echo '
					<div class="', $context['suggested_method'] == 'use_external_tool' || $context['use_maintenance'] != 0 ? 'errorbox' : 'infobox', '">
						', $txt[$context['suggested_method']], $context['use_maintenance'] != 0 ? '
						<br />
						' . $txt['enable_maintenance' . $context['use_maintenance']] : '', '
					</div>
					<p>
						<label for="struct"><input type="checkbox" name="struct" id="struct" onclick="document.getElementById(\'submitDump\').disabled = !document.getElementById(\'struct\').checked &amp;&amp; !document.getElementById(\'data\').checked;" class="input_check" checked="checked" /> ', $txt['maintain_backup_struct'], '</label><br />
						<label for="data"><input type="checkbox" name="data" id="data" onclick="document.getElementById(\'submitDump\').disabled = !document.getElementById(\'struct\').checked &amp;&amp; !document.getElementById(\'data\').checked;" checked="checked" class="input_check" /> ', $txt['maintain_backup_data'], '</label><br />
						<label for="compress"><input type="checkbox" name="compress" id="compress" value="gzip"', $context['suggested_method'] == 'zipped_file' ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['maintain_backup_gz'], '</label>
						</p>';
    }
    if (empty($context['skip_security'])) {
        echo '
					<div class="infobox">', $txt['security_database_download'], '</div>';
        template_control_chmod();
    }
    echo '
					<div class="submitbutton">
						<input ', $context['use_maintenance'] == 2 ? 'disabled="disabled" ' : '', 'type="submit" value="', $txt['maintain_backup_save'], '" id="submitDump" onclick="return document.getElementById(\'struct\').checked || document.getElementById(\'data\').checked;" class="button_submit" />';
    echo '
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
						<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '" />
					</div>
				</form>
			</div>
		</div>';
    // Show an option to convert the body column of the post table to MEDIUMTEXT or TEXT
    if (isset($context['convert_to'])) {
        echo '
		<h3 class="category_header">', $txt[$context['convert_to'] . '_title'], '</h3>
		<div class="windowbg">
			<div class="content">
				<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="UTF-8">
					<p>', $txt['mediumtext_introduction'], '</p>', $context['convert_to_suggest'] ? '<p class="successbox">' . $txt['convert_to_suggest_text'] . '</p>' : '', '
					<div class="submitbutton">
						<input type="submit" name="evaluate_conversion" value="', $txt['maintain_run_now'], '" class="button_submit" />
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
						<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '" />
					</div>
				</form>
			</div>
		</div>';
    }
    echo '
	</div>';
}