From 2cf6dcef880c280dd458ac0a671ac61bde25942b Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 11 Jan 2015 17:16:16 -0500 Subject: [PATCH] #92 Update admin index.php --- admin/index.php | 105 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 77 insertions(+), 28 deletions(-) diff --git a/admin/index.php b/admin/index.php index 25f222b6..a1951042 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,7 +1,7 @@ verifyResponse($_SERVER["REMOTE_ADDR"], hesk_POST("g-recaptcha-response") ); + } + + if ($resp != null && $resp->success) + { + $_SESSION['img_a_verified']=true; + } + else + { + $hesk_error_buffer['mysecnum']=$hesklang['recaptcha_error']; + } + } // Using PHP generated image else { @@ -235,33 +258,39 @@ function do_login() if ($hesk_settings['autoclose']) { $revision = sprintf($hesklang['thist3'],hesk_date(),$hesklang['auto']); - hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `status`='3', `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') WHERE `status` = '2' AND `lastchange` <= '".hesk_dbEscape( date('Y-m-d H:i:s',time() - $hesk_settings['autoclose']*86400) )."'"); - } - - /* Redirect to the destination page */ - if ( hesk_isREQUEST('goto') ) - { - $url = hesk_REQUEST('goto'); - $url = str_replace('&','&',$url); - - /* goto parameter can be set to the local domain only */ - $myurl = parse_url($hesk_settings['hesk_url']); - $goto = parse_url($url); + $dt = date('Y-m-d H:i:s',time() - $hesk_settings['autoclose']*86400); - if (isset($myurl['host']) && isset($goto['host'])) + // Notify customer of closed ticket? + if ($hesk_settings['notify_closed']) { - if ( str_replace('www.','',strtolower($myurl['host'])) != str_replace('www.','',strtolower($goto['host'])) ) + //TODO Change status ID to the ID which customer's replies update the status to. + // Get list of tickets + $result = hesk_dbQuery("SELECT * FROM `".$hesk_settings['db_pfix']."tickets` WHERE `status` = '2' AND `lastchange` <= '".hesk_dbEscape($dt)."' "); + if (hesk_dbNumRows($result) > 0) { - $url = 'admin_main.php'; + global $ticket; + + // Load required functions? + if ( ! function_exists('hesk_notifyCustomer') ) + { + require(HESK_PATH . 'inc/email_functions.inc.php'); + } + + while ($ticket = hesk_dbFetchAssoc($result)) + { + $ticket['dt'] = hesk_date($ticket['dt'], true); + $ticket['lastchange'] = hesk_date($ticket['lastchange'], true); + hesk_notifyCustomer('ticket_closed'); + } } } - header('Location: '.$url); - } - else - { - header('Location: admin_main.php'); - } + // Update ticket statuses and history in database + hesk_dbQuery("UPDATE `".$hesk_settings['db_pfix']."tickets` SET `status`='3', `closedat`=NOW(), `closedby`='-1', `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') WHERE `status` = '2' AND `lastchange` <= '".hesk_dbEscape($dt)."' "); + } + + /* Redirect to the destination page */ + header('Location: ' . hesk_verifyGoto() ); exit(); } // End do_login() @@ -269,6 +298,13 @@ function do_login() function print_login() { global $hesk_settings, $hesklang; + + // Tell header to load reCaptcha API if needed + if ($hesk_settings['recaptcha_use'] == 2) + { + define('RECAPTCHA',1); + } + $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' .$hesklang['admin_login']; require_once(HESK_PATH . 'inc/header.inc.php'); @@ -327,7 +363,7 @@ function print_login() if ($hesk_settings['list_users']) { echo '