From 60a708712b6e7a19313dbcbdfe75bba118ae5651 Mon Sep 17 00:00:00 2001 From: Rod Roark Date: Tue, 2 Nov 2010 10:42:11 -0700 Subject: [PATCH] Added administrative page for editing and uploading site-specific files. --- interface/globals.php | 2 +- interface/main/left_nav.php | 2 + interface/super/manage_site_files.php | 180 +++++++++++++++++++++ interface/usergroup/usergroup_navigation.php | 5 + .../default/images/login_logo.gif | Bin 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 interface/super/manage_site_files.php rename interface/pic/logo_sky.gif => sites/default/images/login_logo.gif (100%) diff --git a/interface/globals.php b/interface/globals.php index 592fe8fca..f43ceb06d 100644 --- a/interface/globals.php +++ b/interface/globals.php @@ -297,7 +297,7 @@ if ($GLOBALS['concurrent_layout']) { } $login_filler_line = ' bgcolor="#f7f0d5" '; $login_body_line = ' background="'.$rootdir.'/pic/aquabg.gif" '; -$logocode=""; +$logocode = ""; $linepic = "$rootdir/pic/repeat_vline9.gif"; $table_bg = ' bgcolor="#cccccc" '; $GLOBALS['style']['BGCOLOR1'] = "#cccccc"; diff --git a/interface/main/left_nav.php b/interface/main/left_nav.php index 455201d17..97362f248 100644 --- a/interface/main/left_nav.php +++ b/interface/main/left_nav.php @@ -877,6 +877,7 @@ function removeOptionSelected(EncounterId) + @@ -984,6 +985,7 @@ if (!empty($reg)) { + diff --git a/interface/super/manage_site_files.php b/interface/super/manage_site_files.php new file mode 100644 index 000000000..7c12393aa --- /dev/null +++ b/interface/super/manage_site_files.php @@ -0,0 +1,180 @@ + +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This module provides for editing site-specific text files and +// for uploading site-specific image files. + +// Disable magic quotes and fake register globals. +$sanitize_all_escapes = true; +$fake_register_globals = false; + +require_once("../globals.php"); +require_once("$srcdir/acl.inc"); +require_once("$srcdir/formdata.inc.php"); + +if (!acl_check('admin', 'super')) die(xl('Not authorized','','','!')); + +// Prepare array of names of editable files, relative to the site directory. +$my_files = array( + "clickoptions.txt", + "config.php", + "faxcover.txt", + "faxtitle.eps", + "referral_template.html", + "statement.inc.php", + "letter_templates/custom_pdf.php", +); +// Append LBF plugin filenames to the array. +$lres = sqlStatement("SELECT * FROM list_options " . + "WHERE list_id = 'lbfnames' ORDER BY seq, title"); +while ($lrow = sqlFetchArray($lres)) { + $option_id = $lrow['option_id']; // should start with LBF + $title = $lrow['title']; + $my_files[] = "LBF/$option_id.plugin.php"; +} + +$form_filename = strip_escape_custom($_REQUEST['form_filename']); +// Sanity check to prevent evildoing. +if (!in_array($form_filename, $my_files)) $form_filename = ''; +$filepath = "$OE_SITE_DIR/$form_filename"; + +$imagedir = "$OE_SITE_DIR/images"; + +if (!empty($_POST['bn_save'])) { + if ($form_filename) { + // Textareas, at least in Firefox, return a \r\n at the end of each line + // even though only \n was originally there. For consistency with + // normal OpenEMR usage we translate those back. + file_put_contents($filepath, str_replace("\r\n", "\n", + strip_escape_custom($_POST['form_filedata']))); + $form_filename = ''; + } + + // Handle uploads. + if (is_uploaded_file($_FILES['form_image']['tmp_name']) && $_FILES['form_image']['size']) { + $form_dest_filename = strip_escape_custom($_POST['form_dest_filename']); + if ($form_dest_filename == '') { + $form_dest_filename = $_FILES['form_image']['name']; + } + $form_dest_filename = basename($form_dest_filename); + if ($form_dest_filename == '') { + die(xl('Cannot find a destination filename')); + } + $imagepath = "$imagedir/$form_dest_filename"; + // If the site's image directory does not yet exist, create it. + if (!is_dir($imagedir)) { + mkdir($imagedir); + } + if (is_file($imagepath)) unlink($imagepath); + $tmp_name = $_FILES['form_image']['tmp_name']; + if (!move_uploaded_file($_FILES['form_image']['tmp_name'], $imagepath)) { + die(xl('Unable to create') . " '$imagepath'"); + } + } +} +?> + + + +<?php xl('File management','e'); ?> + + + + + + + + + +
+ +
+ +

+ + + + + + + + + + + + + + + + + + +
+ +
+ +
+ : + +   + : + +
+ +

+' /> +

+ +
+ +
+ + + diff --git a/interface/usergroup/usergroup_navigation.php b/interface/usergroup/usergroup_navigation.php index f7915e8ce..afd4a3183 100644 --- a/interface/usergroup/usergroup_navigation.php +++ b/interface/usergroup/usergroup_navigation.php @@ -113,6 +113,11 @@ include_once("../../library/acl.inc"); title="Form Layout Management">  +   + +    diff --git a/interface/pic/logo_sky.gif b/sites/default/images/login_logo.gif similarity index 100% rename from interface/pic/logo_sky.gif rename to sites/default/images/login_logo.gif -- 2.11.4.GIT