2010-01-27 08:54:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of the Froxlor project.
|
|
|
|
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the COPYING
|
|
|
|
* file that was distributed with this source code. You can also view the
|
|
|
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
|
|
|
*
|
|
|
|
* @copyright (c) the authors
|
|
|
|
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
|
|
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
|
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
|
|
|
* @package Panel
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2010-01-27 08:54:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
define('AREA', 'admin');
|
|
|
|
require ("./lib/init.php");
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (isset($_POST['subjectid'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$subjectid = intval($_POST['subjectid']);
|
|
|
|
$mailbodyid = intval($_POST['mailbodyid']);
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} elseif(isset($_GET['subjectid'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$subjectid = intval($_GET['subjectid']);
|
|
|
|
$mailbodyid = intval($_GET['mailbodyid']);
|
|
|
|
}
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (isset($_POST['id'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$id = intval($_POST['id']);
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} elseif(isset($_GET['id'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$id = intval($_GET['id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$available_templates = array(
|
|
|
|
'createcustomer',
|
|
|
|
'pop_success',
|
2010-08-10 09:21:07 +00:00
|
|
|
'new_database_by_customer',
|
2010-08-17 06:19:57 +00:00
|
|
|
'new_ftpaccount_by_customer',
|
|
|
|
'password_reset'
|
2010-01-27 08:54:31 +00:00
|
|
|
);
|
2013-04-15 06:56:50 +00:00
|
|
|
|
|
|
|
// only show templates of features that are enabled #1191
|
|
|
|
if ((int)$settings['system']['report_enable'] == 1) {
|
|
|
|
array_push($available_templates,
|
|
|
|
'trafficmaxpercent',
|
|
|
|
'diskmaxpercent'
|
|
|
|
);
|
|
|
|
}
|
2013-11-02 11:07:34 +00:00
|
|
|
|
2013-04-15 06:56:50 +00:00
|
|
|
if ((int)$settings['ticket']['enabled'] == 1) {
|
|
|
|
array_push($available_templates,
|
|
|
|
'new_ticket_by_customer',
|
|
|
|
'new_ticket_for_customer',
|
|
|
|
'new_ticket_by_staff',
|
|
|
|
'new_reply_ticket_by_customer',
|
|
|
|
'new_reply_ticket_by_staff'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$file_templates = array(
|
|
|
|
'index_html'
|
|
|
|
);
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if ($action == '') {
|
2010-01-27 08:54:31 +00:00
|
|
|
//email templates
|
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_templates");
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if ($settings['panel']['sendalternativemail'] == 1) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$available_templates[] = 'pop_success_alternative';
|
|
|
|
}
|
|
|
|
|
|
|
|
$templates_array = array();
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `templategroup`='mails'
|
|
|
|
ORDER BY `language`, `varname`"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$parts = array();
|
|
|
|
preg_match('/^([a-z]([a-z_]+[a-z])*)_(mailbody|subject)$/', $row['varname'], $parts);
|
|
|
|
$templates_array[$row['language']][$parts[1]][$parts[3]] = $row['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$templates = '';
|
2013-11-02 11:07:34 +00:00
|
|
|
foreach ($templates_array as $language => $template_defs) {
|
|
|
|
foreach ($template_defs as $action => $email) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$subjectid = $email['subject'];
|
|
|
|
$mailbodyid = $email['mailbody'];
|
|
|
|
$template = $lng['admin']['templates'][$action];
|
|
|
|
eval("\$templates.=\"" . getTemplate("templates/templates_template") . "\";");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$add = false;
|
2013-11-02 11:07:34 +00:00
|
|
|
while (list($language_file, $language_name) = each($languages)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
|
|
|
|
$templates_done = array();
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `language`= :lang
|
|
|
|
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'lang' => $language_name));
|
|
|
|
|
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$templates_done[] = str_replace('_subject', '', $row['varname']);
|
|
|
|
}
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (count(array_diff($available_templates, $templates_done)) > 0) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$add = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//filetemplates
|
|
|
|
$filetemplates = '';
|
|
|
|
$filetemplateadd = false;
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `templategroup`='files'"
|
|
|
|
);
|
2013-11-07 10:16:38 +00:00
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (Database::num_rows() != count($file_templates)) {
|
|
|
|
$filetemplateadd = true;
|
|
|
|
}
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("\$filetemplates.=\"" . getTemplate("templates/templates_filetemplate") . "\";");
|
|
|
|
}
|
|
|
|
eval("echo \"" . getTemplate("templates/templates") . "\";");
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
} elseif($action == 'delete'
|
|
|
|
&& $subjectid != 0
|
|
|
|
&& $mailbodyid != 0
|
|
|
|
) {
|
|
|
|
//email templates
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `id` = :id"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'id' => $subjectid));
|
|
|
|
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
if ($result['varname'] != '') {
|
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid
|
|
|
|
AND (`id` = :ida OR `id` = :idb)"
|
|
|
|
);
|
|
|
|
Database::pexecute($del_stmt, array(
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'ida' => $subjectid,
|
|
|
|
'idb' => $mailbodyid
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "deleted template '" . $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])] . "'");
|
2013-11-02 11:07:34 +00:00
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
|
|
|
|
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
ask_yesno('admin_template_reallydelete', $filename, array('subjectid' => $subjectid, 'mailbodyid' => $mailbodyid, 'page' => $page, 'action' => $action), $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])]);
|
|
|
|
}
|
|
|
|
}
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} elseif($action == 'deletef'
|
|
|
|
&& $id != 0
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
//file templates
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `id` = :id"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'id' => $id));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (Database::num_rows() > 0) {
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
$row = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `id` = :id"
|
|
|
|
);
|
|
|
|
Database::pexecute($del_stmt, array('adminid' => $userinfo['adminid'], 'id' => $id));
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "deleted template '" . $lng['admin']['templates'][$row['varname']] . "'");
|
2013-11-02 11:07:34 +00:00
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
|
|
|
|
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
ask_yesno('admin_template_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $lng['admin']['templates'][$row['varname']]);
|
|
|
|
}
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('templatenotfound');
|
|
|
|
exit;
|
|
|
|
}
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} elseif($action == 'add') {
|
|
|
|
|
|
|
|
if ($settings['panel']['sendalternativemail'] == 1) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$available_templates[] = 'pop_success_alternative';
|
|
|
|
}
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (isset($_POST['prepare'])
|
|
|
|
&& $_POST['prepare'] == 'prepare'
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
//email templates
|
|
|
|
$language = validate($_POST['language'], 'language');
|
|
|
|
$templates = array();
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid`= :adminid AND `language`= :lang
|
2013-11-07 10:16:38 +00:00
|
|
|
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"
|
2013-11-02 11:07:34 +00:00
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'lang' => $language));
|
|
|
|
|
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$templates[] = str_replace('_subject', '', $row['varname']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$templates = array_diff($available_templates, $templates);
|
|
|
|
$template_options = '';
|
2013-11-02 11:07:34 +00:00
|
|
|
foreach ($templates as $template) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$template_options.= makeoption($lng['admin']['templates'][$template], $template, NULL, true);
|
|
|
|
}
|
|
|
|
|
2011-02-08 11:53:24 +00:00
|
|
|
$template_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.template_add.php';
|
|
|
|
$template_add_form = htmlform::genHTMLForm($template_add_data);
|
|
|
|
|
|
|
|
$title = $template_add_data['template_add']['title'];
|
|
|
|
$image = $template_add_data['template_add']['image'];
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("echo \"" . getTemplate("templates/templates_add_2") . "\";");
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
} elseif(isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
|
|
|
//email templates
|
2010-01-27 08:54:31 +00:00
|
|
|
$language = validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect');
|
|
|
|
$template = validate($_POST['template'], 'template');
|
|
|
|
$subject = validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
|
|
|
|
$mailbody = validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
|
|
|
|
$templates = array();
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `language` = :lang
|
|
|
|
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'lang' => $language));
|
|
|
|
|
|
|
|
while($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$templates[] = str_replace('_subject', '', $row['varname']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$templates = array_diff($available_templates, $templates);
|
2013-11-02 11:07:34 +00:00
|
|
|
if (array_search($template, $templates) === false) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('templatenotfound');
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET
|
|
|
|
`adminid` = :adminid,
|
|
|
|
`language` = :lang,
|
|
|
|
`templategroup` = 'mails',
|
|
|
|
`varname` = :var,
|
|
|
|
`value` = :value"
|
|
|
|
);
|
|
|
|
|
|
|
|
// mail-subject
|
|
|
|
$ins_data = array(
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'lang' => $language,
|
|
|
|
'var' => $template.'_subject',
|
|
|
|
'value' => $subject
|
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
|
|
|
|
// mail-body
|
|
|
|
$ins_data = array(
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'lang' => $language,
|
|
|
|
'var' => $template.'_mailbody',
|
|
|
|
'value' => $mailbody
|
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "added template '" . $language . ' - ' . $template . "'");
|
2013-11-02 11:07:34 +00:00
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
} elseif(isset($_POST['filesend'])
|
|
|
|
&& $_POST['filesend'] == 'filesend'
|
|
|
|
) {
|
|
|
|
//file templates
|
2010-01-27 08:54:31 +00:00
|
|
|
$template = validate($_POST['template'], 'template');
|
|
|
|
$filecontent = validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET
|
|
|
|
`adminid` = :adminid,
|
|
|
|
`language` = '',
|
2013-11-07 10:16:38 +00:00
|
|
|
`templategroup` = 'files',
|
2013-11-02 11:07:34 +00:00
|
|
|
`varname` = :var,
|
|
|
|
`value` = :value"
|
|
|
|
);
|
|
|
|
|
|
|
|
$ins_data = array(
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'var' => $template,
|
|
|
|
'value' => $filecontent
|
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "added template '" . $template . "'");
|
2013-11-02 11:07:34 +00:00
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
} elseif(!isset($_GET['files'])) {
|
|
|
|
|
|
|
|
//email templates
|
2010-01-27 08:54:31 +00:00
|
|
|
$add = false;
|
|
|
|
$language_options = '';
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
while (list($language_file, $language_name) = each($languages)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$templates = array();
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `language` = :lang
|
|
|
|
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'lang' => $language_name));
|
|
|
|
|
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$templates[] = str_replace('_subject', '', $row['varname']);
|
|
|
|
}
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (count(array_diff($available_templates, $templates)) > 0) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$add = true;
|
|
|
|
$language_options.= makeoption($language_name, $language_file, $userinfo['language'], true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if ($add) {
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("echo \"" . getTemplate("templates/templates_add_1") . "\";");
|
2013-11-02 11:07:34 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('alltemplatesdefined');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
} else {
|
|
|
|
//filetemplates
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `templategroup`='files'"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (Database::num_rows() == count($file_templates)) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('alltemplatesdefined');
|
|
|
|
exit;
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$templatesdefined = array();
|
|
|
|
$free_templates = '';
|
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
$templatesdefined[] = $row['varname'];
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (array_diff($file_templates, $templatesdefined) as $template) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$free_templates.= makeoption($lng['admin']['templates'][$template], $template, '', true);
|
|
|
|
}
|
|
|
|
|
2011-02-08 11:53:24 +00:00
|
|
|
$filetemplate_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.filetemplate_add.php';
|
|
|
|
$filetemplate_add_form = htmlform::genHTMLForm($filetemplate_add_data);
|
|
|
|
|
|
|
|
$title = $filetemplate_add_data['filetemplate_add']['title'];
|
|
|
|
$image = $filetemplate_add_data['filetemplate_add']['image'];
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("echo \"" . getTemplate("templates/filetemplates_add") . "\";");
|
|
|
|
}
|
|
|
|
}
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} elseif($action == 'edit'
|
|
|
|
&& $subjectid != 0
|
|
|
|
&& $mailbodyid != 0
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
//email templates
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `language`, `varname`, `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `id` = :subjectid"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'subjectid' => $subjectid));
|
|
|
|
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if ($result['varname'] != '') {
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$subject = validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
|
|
|
|
$mailbody = validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET
|
|
|
|
`value` = :value
|
|
|
|
WHERE `adminid` = :adminid AND `id` = :id"
|
|
|
|
);
|
|
|
|
// subject
|
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'value' => $subject,
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'id' => $subjectid
|
|
|
|
));
|
|
|
|
// same query but mailbody
|
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'value' => $mailbody,
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'id' => $mailbodyid
|
|
|
|
));
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "edited template '" . $result['varname'] . "'");
|
2013-11-02 11:07:34 +00:00
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$result = htmlentities_array($result);
|
|
|
|
$template = $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])];
|
|
|
|
$subject = $result['value'];
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `language`, `varname`, `value`
|
|
|
|
FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `id` = :id"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('id' => $mailbodyid));
|
|
|
|
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$result = htmlentities_array($result);
|
|
|
|
$mailbody = $result['value'];
|
2011-02-08 11:53:24 +00:00
|
|
|
|
|
|
|
$template_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.template_edit.php';
|
|
|
|
$template_edit_form = htmlform::genHTMLForm($template_edit_data);
|
|
|
|
|
|
|
|
$title = $template_edit_data['template_edit']['title'];
|
|
|
|
$image = $template_edit_data['template_edit']['image'];
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("echo \"" . getTemplate("templates/templates_edit") . "\";");
|
|
|
|
}
|
|
|
|
}
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} elseif($action == 'editf'
|
|
|
|
&& $id != 0
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
//file templates
|
2013-11-02 11:07:34 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `id` = :id"
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'id' => $id));
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
if(Database::num_rows() > 0) {
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-11-02 11:07:34 +00:00
|
|
|
$row = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
|
|
|
//filetemplates
|
2013-11-02 11:07:34 +00:00
|
|
|
if (isset($_POST['filesend'])
|
|
|
|
&& $_POST['filesend'] == 'filesend'
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$filecontent = validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
|
2013-11-02 11:07:34 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET
|
|
|
|
`value` = :value
|
|
|
|
WHERE `adminid` = :adminid AND `id` = :id"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd_stmt, array(
|
|
|
|
'value' => $filecontent,
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'id' => $id
|
|
|
|
));
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "edited template '" . $row['varname'] . "'");
|
2013-11-02 11:07:34 +00:00
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
|
|
|
|
|
|
|
} else {
|
2010-01-30 15:52:53 +00:00
|
|
|
$row = htmlentities_array($row);
|
2011-02-08 11:53:24 +00:00
|
|
|
|
|
|
|
$filetemplate_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.filetemplate_edit.php';
|
|
|
|
$filetemplate_edit_form = htmlform::genHTMLForm($filetemplate_edit_data);
|
|
|
|
|
|
|
|
$title = $filetemplate_edit_data['filetemplate_edit']['title'];
|
|
|
|
$image = $filetemplate_edit_data['filetemplate_edit']['image'];
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("echo \"" . getTemplate("templates/filetemplates_edit") . "\";");
|
|
|
|
}
|
2013-11-02 11:07:34 +00:00
|
|
|
|
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('templatenotfound');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|