function hesk_testLanguage($return_options = 0) { global $hesk_settings, $hesklang; /* Get a list of valid emails */ include_once HESK_PATH . 'inc/email_functions.inc.php'; $valid_emails = array_keys(hesk_validEmails()); $dir = HESK_PATH . 'language/'; $path = opendir($dir); $text = ''; $html = ''; $text .= "/language\n"; /* Test all folders inside the language folder */ while (false !== ($subdir = readdir($path))) { if ($subdir == "." || $subdir == "..") { continue; } if (filetype($dir . $subdir) == 'dir') { $add = 1; $langu = $dir . $subdir . '/text.php'; $email = $dir . $subdir . '/emails'; /* Check the text.php */ $text .= " |-> /{$subdir}\n"; $text .= " |-> text.php: "; if (file_exists($langu)) { $tmp = file_get_contents($langu); // Some servers add slashes to file_get_contents output if (strpos($tmp, '[\\\'LANGUAGE\\\']') !== false) { $tmp = stripslashes($tmp); } $err = ''; if (!preg_match('/\\$hesklang\\[\'LANGUAGE\'\\]\\=\'(.*)\'\\;/', $tmp, $l)) { $err .= " |----> MISSING: \$hesklang['LANGUAGE']\n"; } if (strpos($tmp, '$hesklang[\'ENCODING\']') === false) { $err .= " |----> MISSING: \$hesklang['ENCODING']\n"; } if (strpos($tmp, '$hesklang[\'_COLLATE\']') === false) { $err .= " |----> MISSING: \$hesklang['_COLLATE']\n"; } if (strpos($tmp, '$hesklang[\'EMAIL_HR\']') === false) { $err .= " |----> MISSING: \$hesklang['EMAIL_HR']\n"; } /* Check if language file is for current version */ if (strpos($tmp, '$hesklang[\'recaptcha_error\']') === false) { $err .= " |----> WRONG VERSION (not " . $hesk_settings['hesk_version'] . ")\n"; } if ($err) { $text .= "ERROR\n" . $err; $add = 0; } else { $l[1] = hesk_input($l[1]); $l[1] = str_replace('|', ' ', $l[1]); $text .= "OK ({$l['1']})\n"; } } else { $text .= "ERROR\n"; $text .= " |----> MISSING: text.php\n"; $add = 0; } /* Check emails folder */ $text .= " |-> /emails: "; if (file_exists($email) && filetype($email) == 'dir') { $err = ''; foreach ($valid_emails as $eml) { if (!file_exists($email . '/' . $eml . '.txt')) { $err .= " |----> MISSING: {$eml}.txt\n"; } } if ($err) { $text .= "ERROR\n" . $err; $add = 0; } else { $text .= "OK\n"; } } else { $text .= "ERROR\n"; $text .= " |----> MISSING: /emails folder\n"; $add = 0; } $text .= "\n"; /* Add an option for the <select> if needed */ if ($add) { if ($l[1] == $hesk_settings['language']) { $html .= '<option value="' . $subdir . '|' . $l[1] . '" selected="selected">' . $l[1] . '</option>'; } else { $html .= '<option value="' . $subdir . '|' . $l[1] . '">' . $l[1] . '</option>'; } } } } closedir($path); /* Output select options or the test log for debugging */ if ($return_options) { return $html; } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML; 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title><?php echo $hesklang['s_inl']; ?> </title> <meta http-equiv="Content-Type" content="text/html;charset=<?php echo $hesklang['ENCODING']; ?> " /> <style type="text/css"> body { margin:5px 5px; padding:0; background:#fff; color: black; font : 68.8%/1.5 Verdana, Geneva, Arial, Helvetica, sans-serif; text-align:left; } p { color : black; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 1.0em; } h3 { color : #AF0000; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 1.0em; text-align:center; } .title { color : black; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 1.0em; } .wrong {color : red;} .correct {color : green;} pre {font-size:1.2em;} </style> </head> <body> <h3><?php echo $hesklang['s_inl']; ?> </h3> <p><i><?php echo $hesklang['s_inle']; ?> </i></p> <pre><?php echo $text; ?> </pre> <p> </p> <p align="center"><a href="admin_settings.php?test_languages=1&<?php echo rand(10000, 99999); ?> "><?php echo $hesklang['ta']; ?> </a> | <a href="#" onclick="Javascript:window.close()"><?php echo $hesklang['cwin']; ?> </a></p> <p> </p> </body> </html> <?php exit; } }
function hesk_getLanguagesArray($returnArray = 0) { global $hesk_settings, $hesklang; /* Get a list of valid emails */ $hesk_settings['smtp'] = 0; $valid_emails = array_keys(hesk_validEmails()); $dir = HESK_PATH . 'language/'; $path = opendir($dir); $code = ''; $langArray = array(); /* Test all folders inside the language folder */ while (false !== ($subdir = readdir($path))) { if ($subdir == "." || $subdir == "..") { continue; } if (filetype($dir . $subdir) == 'dir') { $add = 1; $langu = $dir . $subdir . '/text.php'; $email = $dir . $subdir . '/emails'; /* Check the text.php */ if (file_exists($langu)) { $tmp = file_get_contents($langu); // Some servers add slashes to file_get_contents output if (strpos($tmp, '[\\\'LANGUAGE\\\']') !== false) { $tmp = stripslashes($tmp); } $err = ''; if (!preg_match('/\\$hesklang\\[\'LANGUAGE\'\\]\\=\'(.*)\'\\;/', $tmp, $l)) { $add = 0; } elseif (!preg_match('/\\$hesklang\\[\'ENCODING\'\\]\\=\'(.*)\'\\;/', $tmp)) { $add = 0; } elseif (!preg_match('/\\$hesklang\\[\'_COLLATE\'\\]\\=\'(.*)\'\\;/', $tmp)) { $add = 0; } elseif (!preg_match('/\\$hesklang\\[\'EMAIL_HR\'\\]\\=\'(.*)\'\\;/', $tmp, $hr)) { $add = 0; } elseif (!preg_match('/\\$hesklang\\[\'ms01\'\\]/', $tmp)) { $add = 0; } } else { $add = 0; } /* Check emails folder */ if (file_exists($email) && filetype($email) == 'dir') { foreach ($valid_emails as $eml) { if (!file_exists($email . '/' . $eml . '.txt')) { $add = 0; } } } else { $add = 0; } /* Add an option for the <select> if needed */ if ($add) { $code .= "'" . addslashes($l[1]) . "' => array('folder'=>'" . $subdir . "','hr'=>'" . addslashes($hr[1]) . "'),\n"; $langArray[] = $l[1]; } } } closedir($path); if ($returnArray) { return $langArray; } else { return $code; } }
function hesk_getEmailMessage($eml_file, $ticket, $is_admin = 0, $is_ticket = 1, $just_message = 0) { global $hesk_settings, $hesklang; // Demo mode if (defined('HESK_DEMO')) { return ''; } /* Get list of valid emails */ $valid_emails = hesk_validEmails(); /* Verify this is a valid email include */ if (!isset($valid_emails[$eml_file])) { hesk_error($hesklang['inve']); } /* Get email template */ $eml_file = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/emails/' . $eml_file . '.txt'; if (file_exists(HESK_PATH . $eml_file)) { $msg = file_get_contents(HESK_PATH . $eml_file); } else { hesk_error($hesklang['emfm'] . ': ' . $eml_file); } $msg = hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message); return $msg; }
function hesk_getEmailMessage($eml_file, $ticket, $is_admin = 0, $is_ticket = 1, $just_message = 0) { global $hesk_settings, $hesklang; // Demo mode if (defined('HESK_DEMO')) { return ''; } /* Get list of valid emails */ $valid_emails = hesk_validEmails(); /* Verify this is a valid email include */ if (!isset($valid_emails[$eml_file])) { hesk_error($hesklang['inve']); } /* Get email template */ $eml_file = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/emails/' . $eml_file . '.txt'; if (file_exists(HESK_PATH . $eml_file)) { $msg = file_get_contents(HESK_PATH . $eml_file); } else { hesk_error($hesklang['emfm'] . ': ' . $eml_file); } /* Return just the message without any processing? */ if ($just_message) { return $msg; } // Convert any entities in site title to plain text $hesk_settings['site_title'] = hesk_msgToPlain($hesk_settings['site_title'], 1); /* If it's not a ticket-related mail (like "a new PM") just process quickly */ if (!$is_ticket) { $trackingURL = $hesk_settings['hesk_url'] . '/' . $hesk_settings['admin_dir'] . '/mail.php?a=read&id=' . intval($ticket['id']); $msg = str_replace('%%NAME%%', $ticket['name'], $msg); $msg = str_replace('%%SUBJECT%%', $ticket['subject'], $msg); $msg = str_replace('%%TRACK_URL%%', $trackingURL, $msg); $msg = str_replace('%%SITE_TITLE%%', $hesk_settings['site_title'], $msg); $msg = str_replace('%%SITE_URL%%', $hesk_settings['site_url'], $msg); if (isset($ticket['message'])) { return str_replace('%%MESSAGE%%', $ticket['message'], $msg); } else { return $msg; } } // Is email required to view ticket (for customers only)? $hesk_settings['e_param'] = $hesk_settings['email_view_ticket'] ? '&e=' . rawurlencode($ticket['email']) : ''; /* Generate the ticket URLs */ $trackingURL = $hesk_settings['hesk_url']; $trackingURL .= $is_admin ? '/' . $hesk_settings['admin_dir'] . '/admin_ticket.php' : '/ticket.php'; $trackingURL .= '?track=' . $ticket['trackid'] . ($is_admin ? '' : $hesk_settings['e_param']) . '&Refresh=' . rand(10000, 99999); /* Set category title */ $ticket['category'] = hesk_msgToPlain(hesk_getCategoryName($ticket['category']), 1); /* Set priority title */ switch ($ticket['priority']) { case 0: $ticket['priority'] = $hesklang['critical']; break; case 1: $ticket['priority'] = $hesklang['high']; break; case 2: $ticket['priority'] = $hesklang['medium']; break; default: $ticket['priority'] = $hesklang['low']; } /* Get owner name */ $ticket['owner'] = hesk_msgToPlain(hesk_getOwnerName($ticket['owner']), 1); /* Set status */ switch ($ticket['status']) { case 1: $ticket['status'] = $hesklang['wait_reply']; break; case 2: $ticket['status'] = $hesklang['replied']; break; case 3: $ticket['status'] = $hesklang['closed']; break; case 4: $ticket['status'] = $hesklang['in_progress']; break; case 5: $ticket['status'] = $hesklang['on_hold']; break; default: $ticket['status'] = $hesklang['open']; } /* Replace all special tags */ $msg = str_replace('%%NAME%%', $ticket['name'], $msg); $msg = str_replace('%%SUBJECT%%', $ticket['subject'], $msg); $msg = str_replace('%%TRACK_ID%%', $ticket['trackid'], $msg); $msg = str_replace('%%TRACK_URL%%', $trackingURL, $msg); $msg = str_replace('%%SITE_TITLE%%', $hesk_settings['site_title'], $msg); $msg = str_replace('%%SITE_URL%%', $hesk_settings['site_url'], $msg); $msg = str_replace('%%CATEGORY%%', $ticket['category'], $msg); $msg = str_replace('%%PRIORITY%%', $ticket['priority'], $msg); $msg = str_replace('%%OWNER%%', $ticket['owner'], $msg); $msg = str_replace('%%STATUS%%', $ticket['status'], $msg); $msg = str_replace('%%EMAIL%%', $ticket['email'], $msg); $msg = str_replace('%%CREATED%%', $ticket['dt'], $msg); $msg = str_replace('%%UPDATED%%', $ticket['lastchange'], $msg); $msg = str_replace('%%ID%%', $ticket['id'], $msg); /* All custom fields */ foreach ($hesk_settings['custom_fields'] as $k => $v) { if ($v['use']) { if ($v['type'] == 'checkbox') { $ticket[$k] = str_replace("<br />", "\n", $ticket[$k]); } $msg = str_replace('%%' . strtoupper($k) . '%%', stripslashes($ticket[$k]), $msg); } else { $msg = str_replace('%%' . strtoupper($k) . '%%', '', $msg); } } // Is message tag in email template? if (strpos($msg, '%%MESSAGE%%') !== false) { // Replace message $msg = str_replace('%%MESSAGE%%', $ticket['message'], $msg); // Add direct links to any attachments at the bottom of the email message if ($hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments'])) { $msg .= "\n\n\n" . $hesklang['fatt']; $att = explode(',', substr($ticket['attachments'], 0, -1)); foreach ($att as $myatt) { list($att_id, $att_name) = explode('#', $myatt); $msg .= "\n\n" . $att_name . "\n" . $hesk_settings['hesk_url'] . '/download_attachment.php?att_id=' . $att_id . '&track=' . $ticket['trackid'] . $hesk_settings['e_param']; } } // For customer notifications: if we allow email piping/pop 3 fetching and // stripping quoted replies add an "reply above this line" tag if (!$is_admin && ($hesk_settings['email_piping'] || $hesk_settings['pop3']) && $hesk_settings['strip_quoted']) { $msg = $hesklang['EMAIL_HR'] . "\n\n" . $msg; } } return $msg; }