check_feature('feature_webmail'); $access->check_permission_either(['tiki_p_use_webmail', 'tiki_p_use_group_webmail']); $access->check_user($user); if (empty($_SESSION['cypht']['username']) || $_SESSION['cypht']['username'] != $user) { unset($_SESSION['cypht']); $headerlib = TikiLib::lib('header'); $headerlib->add_js(' document.cookie = "hm_reload_folders=1"; for(var i =0; i < sessionStorage.length; i++){ var key = sessionStorage.key(i); if (key.indexOf(window.location.pathname) > -1) { sessionStorage.removeItem(key); } } '); } if ( empty($_SESSION['cypht']['preference_name']) || $_SESSION['cypht']['preference_name'] != 'cypht_user_config' || (! empty($_SESSION['cypht']['username']) && $_SESSION['cypht']['username'] != $user) || !empty($_REQUEST['clear_cache']) ) { // resetting the session on purpose - could be coming from PluginCypht $_SESSION['cypht'] = []; $_SESSION['cypht']['preference_name'] = 'cypht_user_config'; } define('VENDOR_PATH', $tikipath . '/vendor_bundled/vendor/'); define('APP_PATH', VENDOR_PATH . 'jason-munro/cypht/'); define('WEB_ROOT', $tikiroot . 'vendor_bundled/vendor/jason-munro/cypht/'); define('DEBUG_MODE', false); define('CACHE_ID', 'FoHc85ubt5miHBls6eJpOYAohGhDM61Vs%2Fm0BOxZ0N0%3D'); // Cypht uses for asset cache busting but we run the assets through Tiki pipeline, so no need to generate a unique key here define('SITE_ID', 'Tiki-Integration'); /* get includes */ require_once APP_PATH . 'lib/framework.php'; require_once $tikipath . '/lib/cypht/integration/classes.php'; if (empty($_SESSION['cypht']['request_key'])) { $_SESSION['cypht']['request_key'] = Hm_Crypt::unique_id(); } $_SESSION['cypht']['username'] = $user; /* get configuration */ $config = new Tiki_Hm_Site_Config_File(APP_PATH . 'hm3.rc'); /* process the request */ $dispatcher = new Hm_Dispatch($config); if (! empty($_SESSION['cypht']['user_data']['debug_mode_setting'])) { $msgs = Hm_Debug::get(); foreach ($msgs as $msg) { $logslib->add_log('cypht', $msg); } } $smarty->assign('output_data', '
' . $dispatcher->output . "
"); $smarty->assign('mid', 'tiki-webmail.tpl'); //handle message priting if (isset($_POST['display']) && $_POST['display'] == 'pdf') { require_once 'lib/pdflib.php'; $generator = new PdfGenerator(PdfGenerator::MPDF); if (! empty($generator->error)) { Feedback::error($generator->error); } else { if (isset($_POST['uid'])) { $uid = $_POST['uid']; } if (isset($_POST['list_path'])) { $list_path = $_POST['list_path']; } if (isset($_POST['header_subject'])) { $header_subject = $_POST['header_subject']; } if (isset($_POST['header_date'])) { $header_date = $_POST['header_date']; } if (isset($_POST['header_from'])) { $header_from = $_POST['header_from']; } if (isset($_POST['header_to'])) { $header_to = $_POST['header_to']; } if (isset($_POST['msg_text'])) { $msg_text = $_POST['msg_text']; } if (isset($_POST['header_cc'])){ $header_cc = $_POST['header_cc']; } $contentpage = createPage($header_subject, $header_date, $header_from, $header_to, $msg_text, $origin, $header_cc); $filename = $header_from . '_' . $header_subject; $params = [ 'page' => 'messsage', 'uid' => $uid, 'list_path' => $list_path ]; $pdata = '' . $contentpage; $pdf = $generator->getPdf('tiki-webmail.php', $params, preg_replace('/%u([a-fA-F0-9]{4})/', '&#x\\1;', $pdata)); $length = strlen($pdf); header('Cache-Control: private, must-revalidate'); header('Pragma: private'); header("Content-Description: File Transfer"); $filename = preg_replace('/\W+/u', '_', $filename); // Replace non words with underscores for valid file names $filename = \TikiLib::lib('tiki')->remove_non_word_characters_and_accents($filename); header('Content-disposition: attachment; filename="' . $filename . '.pdf"'); header("Content-Type: application/pdf"); header("Content-Transfer-Encoding: binary"); header('Content-Length: ' . $length); echo $pdf; } } $smarty->display('tiki.tpl'); /** * creates the HTML page to be print. */ function createPage($header_subject, $header_date, $header_from, $header_to, $msg_text, $origin, $header_cc) { return <<

WEBMAIL

$header_to

$header_subject

Date $header_date
From $header_from
To $header_to
Cc $header_cc
$msg_text
END; }