Browse Source

#275 Utilize the separated folders option

merge-requests/2/head
Mike Koch 6 years ago
parent
commit
194c4a0dad
  1. 5
      admin/manage_knowledgebase.php
  2. 4
      download_attachment.php
  3. 21
      inc/attachments.inc.php

5
admin/manage_knowledgebase.php

@ -37,6 +37,7 @@ define('HESK_PATH','../');
/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'modsForHesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/admin_functions.inc.php');
hesk_load_database_functions();
@ -1113,7 +1114,7 @@ function save_article()
$attachments = array();
for ($i=1;$i<=3;$i++)
{
$att = hesk_uploadFile($i);
$att = hesk_uploadFile($i, false);
if ( ! empty($att))
{
$attachments[$i] = $att;
@ -1922,7 +1923,7 @@ function new_article()
$attachments = array();
for ($i=1;$i<=3;$i++)
{
$att = hesk_uploadFile($i);
$att = hesk_uploadFile($i, false);
if ( ! empty($att))
{
$attachments[$i] = $att;

4
download_attachment.php

@ -37,6 +37,7 @@ define('HESK_PATH','./');
// Get all the required files and functions
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'modsForHesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
hesk_load_database_functions();
@ -139,6 +140,9 @@ else
// Path of the file on the server
$realpath = $hesk_settings['attach_dir'] . '/' . $file['saved_name'];
if (isset($_GET['kb_att'])) {
$realpath = $modsForHesk_settings['kb_attach_dir'] . '/' . $file['saved_name'];
}
// Perhaps the file has been deleted?
if ( ! file_exists($realpath))

21
inc/attachments.inc.php

@ -38,9 +38,9 @@ if (!defined('IN_SCRIPT')) {die('Invalid attempt');}
/***************************
Function hesk_uploadFiles()
***************************/
function hesk_uploadFile($i)
function hesk_uploadFile($i, $isTicket = true)
{
global $hesk_settings, $hesklang, $trackingID, $hesk_error_buffer;
global $hesk_settings, $hesklang, $trackingID, $hesk_error_buffer, $modsForHesk_settings;
/* Return if name is empty */
if (empty($_FILES['attachment']['name'][$i])) {return '';}
@ -92,7 +92,11 @@ function hesk_uploadFile($i)
*/
/* If upload was successful let's create the headers */
if ( ! move_uploaded_file($_FILES['attachment']['tmp_name'][$i], dirname(dirname(__FILE__)).'/'.$hesk_settings['attach_dir'].'/'.$file_name))
$directory = $hesk_settings['attach_dir'];
if (!$isTicket) {
$directory = $modsForHesk_settings['kb_attach_dir'];
}
if ( ! move_uploaded_file($_FILES['attachment']['tmp_name'][$i], dirname(dirname(__FILE__)).'/'.$directory.'/'.$file_name))
{
return hesk_fileError($hesklang['cannot_move_tmp']);
}
@ -118,11 +122,16 @@ function hesk_fileError($error)
} // End hesk_fileError()
function hesk_removeAttachments($attachments)
function hesk_removeAttachments($attachments, $isTicket)
{
global $hesk_settings, $hesklang;
global $hesk_settings, $hesklang, $modsForHesk_settings;
$directory = $hesk_settings['attach_dir'];
if (!$isTicket) {
$directory = $modsForHesk_settings['kb_attach_dir'];
}
$hesk_settings['server_path'] = dirname(dirname(__FILE__)).'/'.$hesk_settings['attach_dir'].'/';
$hesk_settings['server_path'] = dirname(dirname(__FILE__)).'/'.$directory.'/';
foreach ($attachments as $myatt)
{

Loading…
Cancel
Save