mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Revise picture widget to store inamge on file system, not in XML config
This commit is contained in:
parent
f9b1c1289e
commit
ee28e293c1
@ -74,7 +74,7 @@ $g = array(
|
||||
"disablecrashreporter" => false,
|
||||
"crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php",
|
||||
"debug" => false,
|
||||
"latest_config" => "17.6",
|
||||
"latest_config" => "17.7",
|
||||
"minimum_ram_warning" => "101",
|
||||
"minimum_ram_warning_text" => "128 MB",
|
||||
"wan_interface_name" => "wan",
|
||||
|
||||
@ -5521,4 +5521,18 @@ function upgrade_175_to_176() {
|
||||
}
|
||||
}
|
||||
|
||||
// The image displayed by the picture widget is now stored on the file system
|
||||
function upgrade_176_to_177() {
|
||||
global $config;
|
||||
|
||||
if (isset($config['widgets'])) {
|
||||
$idx = 0;
|
||||
|
||||
while (isset($config['widgets']['picture-' . $idx])) {
|
||||
file_put_contents("/conf/widget_image.picture-" . $idx, base64_decode($config['widgets']['picture-' . $idx]['picturewidget']));
|
||||
$config['widgets']['picture-' . $idx]['picturewidget'] = "/conf/widget_image.picture-". $idx;
|
||||
$idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -27,9 +27,11 @@ require_once("functions.inc");
|
||||
if ($_GET['getpic']=="true") {
|
||||
$pic_type_s = explode(".", $user_settings['widgets'][$_GET['widgetkey']]['picturewidget_filename']);
|
||||
$pic_type = $pic_type_s[1];
|
||||
|
||||
if ($user_settings['widgets'][$_GET['widgetkey']]['picturewidget']) {
|
||||
$data = base64_decode($user_settings['widgets'][$_GET['widgetkey']]['picturewidget']);
|
||||
$data = file_get_contents("/conf/widget_image." . $_GET['widgetkey']);
|
||||
}
|
||||
|
||||
header("Content-Disposition: inline; filename=\"{$user_settings['widgets'][$_GET['widgetkey']]['picturewidget_filename']}\"");
|
||||
header("Content-Type: image/{$pic_type}");
|
||||
header("Content-Length: " . strlen($data));
|
||||
@ -60,7 +62,8 @@ if ($_POST['widgetkey']) {
|
||||
die("Not a gif/jpg/png");
|
||||
}
|
||||
$picname = basename($_FILES['uploadedfile']['name']);
|
||||
$user_settings['widgets'][$_POST['widgetkey']]['picturewidget'] = base64_encode($data);
|
||||
$user_settings['widgets'][$_POST['widgetkey']]['picturewidget'] = "/conf/widget_image";
|
||||
file_put_contents("/conf/widget_image." . $_POST['widgetkey'], $data);
|
||||
$user_settings['widgets'][$_POST['widgetkey']]['picturewidget_filename'] = $_FILES['pictfile']['name'];
|
||||
}
|
||||
}
|
||||
@ -85,7 +88,7 @@ if($user_settings['widgets'][$widgetkey]["picturewidget"] != null){?>
|
||||
<input type="hidden" name="widgetkey" value="<?=htmlspecialchars($widgetkey); ?>">
|
||||
<?=gen_customwidgettitle_div($widgetconfig['title']); ?>
|
||||
<div class="form-group">
|
||||
<label for="pictfile" class="col-sm-4 control-label"><?=gettext('New picture:')?> </label>
|
||||
<label for="pictfile" class="col-sm-4 control-label"><?=gettext('New pictures:')?> </label>
|
||||
<div class="col-sm-6">
|
||||
<input id="pictfile" name="pictfile" type="file" class="form-control" accept="image/*"/>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user