PageRenderTime 72ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/modules/PDFSettings/serverfiles/index.php

https://code.google.com/p/vtiger-ru-fork/
PHP | 850 lines | 646 code | 101 blank | 103 comment | 261 complexity | feff6bd99eb9383556d8d41f77ae6a70 MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, GPL-2.0, LGPL-3.0
  1. <?php
  2. /*********************************************************************************
  3. * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
  4. * ("License"); You may not use this file except in compliance with the
  5. * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
  6. * Software distributed under the License is distributed on an "AS IS" basis,
  7. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  8. * the specific language governing rights and limitations under the License.
  9. * The Original Code is: SugarCRM Open Source
  10. * The Initial Developer of the Original Code is SugarCRM, Inc.
  11. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12. * All Rights Reserved.
  13. * Contributor(s): ______________________________________.
  14. ********************************************************************************/
  15. /*********************************************************************************
  16. * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/index.php,v 1.93 2005/04/21 16:17:25 ray Exp $
  17. * Description: Main file and starting point for the application. Calls the
  18. * theme header and footer files defined for the user as well as the module as
  19. * defined by the input parameters.
  20. ********************************************************************************/
  21. global $entityDel;
  22. global $display;
  23. global $category;
  24. if(version_compare(phpversion(), '5.0') < 0) {
  25. insert_charset_header();
  26. require_once('phpversionfail.php');
  27. die();
  28. }
  29. require_once('include/utils/utils.php');
  30. if (version_compare(phpversion(), '5.0') < 0) {
  31. eval('
  32. function clone($object) {
  33. return $object;
  34. }
  35. ');
  36. }
  37. global $currentModule;
  38. /** Function to return a string with backslashes stripped off
  39. * @param $value -- value:: Type string
  40. * @returns $value -- value:: Type string array
  41. */
  42. function stripslashes_checkstrings($value){
  43. if(is_string($value)){
  44. return stripslashes($value);
  45. }
  46. return $value;
  47. }
  48. if(get_magic_quotes_gpc() == 1){
  49. $_REQUEST = array_map("stripslashes_checkstrings", $_REQUEST);
  50. $_POST = array_map("stripslashes_checkstrings", $_POST);
  51. $_GET = array_map("stripslashes_checkstrings", $_GET);
  52. }
  53. // Allow for the session information to be passed via the URL for printing.
  54. if(isset($_REQUEST['PHPSESSID']))
  55. {
  56. session_id($_REQUEST['PHPSESSID']);
  57. //Setting the same session id to Forums as in CRM
  58. $sid=$_REQUEST['PHPSESSID'];
  59. }
  60. /** Function to set, character set in the header, as given in include/language/*_lang.php
  61. */
  62. function insert_charset_header()
  63. {
  64. global $app_strings, $default_charset;
  65. $charset = $default_charset;
  66. if(isset($app_strings['LBL_CHARSET']))
  67. {
  68. $charset = $app_strings['LBL_CHARSET'];
  69. }
  70. header('Content-Type: text/html; charset='. $charset);
  71. }
  72. insert_charset_header();
  73. // Create or reestablish the current session
  74. session_start();
  75. if (!is_file('config.inc.php')) {
  76. header("Location: install.php");
  77. exit();
  78. }
  79. require_once('config.inc.php');
  80. if (!isset($dbconfig['db_hostname']) || $dbconfig['db_status']=='_DB_STAT_') {
  81. header("Location: install.php");
  82. exit();
  83. }
  84. // load up the config_override.php file. This is used to provide default user settings
  85. if (is_file('config_override.php'))
  86. {
  87. require_once('config_override.php');
  88. }
  89. /**
  90. * Check for vtiger installed version and codebase
  91. */
  92. require_once('vtigerversion.php');
  93. global $adb, $vtiger_current_version;
  94. if(isset($_SESSION['VTIGER_DB_VERSION']) && isset($_SESSION['authenticated_user_id'])) {
  95. if(version_compare($_SESSION['VTIGER_DB_VERSION'], $vtiger_current_version, '!=')) {
  96. unset($_SESSION['VTIGER_DB_VERSION']);
  97. header("Location: install.php");
  98. exit();
  99. }
  100. } else {
  101. $result = $adb->query("SELECT * FROM vtiger_version");
  102. $dbversion = $adb->query_result($result, 0, 'current_version');
  103. if(version_compare($dbversion, $vtiger_current_version, '=')) {
  104. $_SESSION['VTIGER_DB_VERSION']= $dbversion;
  105. } else {
  106. header("Location: install.php");
  107. exit();
  108. }
  109. }
  110. // END
  111. $default_config_values = Array( "allow_exports"=>"all","upload_maxsize"=>"3000000", "listview_max_textlength" => "40", "php_max_execution_time" => "0");
  112. set_default_config($default_config_values);
  113. // Set the default timezone preferred by user
  114. global $default_timezone;
  115. if(isset($default_timezone) && function_exists('date_default_timezone_set')) {
  116. @date_default_timezone_set($default_timezone);
  117. }
  118. require_once('include/logging.php');
  119. require_once('modules/Users/Users.php');
  120. global $currentModule;
  121. //if($calculate_response_time) $startTime = microtime();
  122. $log =& LoggerManager::getLogger('index');
  123. global $seclog;
  124. $seclog =& LoggerManager::getLogger('SECURITY');
  125. if (isset($_REQUEST['PHPSESSID'])) $log->debug("****Starting for session ".$_REQUEST['PHPSESSID']);
  126. else $log->debug("****Starting for new session");
  127. // We use the REQUEST_URI later to construct dynamic URLs. IIS does not pass this field
  128. // to prevent an error, if it is not set, we will assign it to ''
  129. if(!isset($_SERVER['REQUEST_URI']))
  130. {
  131. $_SERVER['REQUEST_URI'] = '';
  132. }
  133. $action = '';
  134. if(isset($_REQUEST['action']))
  135. {
  136. $action = $_REQUEST['action'];
  137. }
  138. if($action == 'Export')
  139. {
  140. include ('include/utils/export.php');
  141. }
  142. if($action == 'ExportAjax')
  143. {
  144. include ('include/utils/ExportAjax.php');
  145. }
  146. // vtlib customization: Module manager export
  147. if($action == 'ModuleManagerExport') {
  148. include('modules/Settings/ModuleManager/Export.php');
  149. }
  150. // END
  151. //Code added for 'Path Traversal/File Disclosure' security fix - Philip
  152. $is_module = false;
  153. $is_action = false;
  154. if(isset($_REQUEST['module']))
  155. {
  156. $module = $_REQUEST['module'];
  157. $dir = @scandir($root_directory."modules");
  158. $temp_arr = Array("CVS","Attic");
  159. $res_arr = @array_intersect($dir,$temp_arr);
  160. if(count($res_arr) == 0 && !preg_match("/[\/.]/",$module)) {
  161. if(@in_array($module,$dir))
  162. $is_module = true;
  163. }
  164. $in_dir = @scandir($root_directory."modules/".$module);
  165. $res_arr = @array_intersect($in_dir,$temp_arr);
  166. if(count($res_arr) == 0 && !preg_match("/[\/.]/",$module)) {
  167. if(@in_array($action.".php",$in_dir))
  168. $is_action = true;
  169. }
  170. if(!$is_module)
  171. {
  172. die("Module name is missing. Please check the module name.");
  173. }
  174. if(!$is_action)
  175. {
  176. die("Action name is missing. Please check the action name.");
  177. }
  178. }
  179. //Code added for 'Multiple SQL Injection Vulnerabilities & XSS issue' fixes - Philip
  180. if(isset($_REQUEST['record']) && !is_numeric($_REQUEST['record']) && $_REQUEST['record']!='')
  181. {
  182. die("An invalid record number specified to view details.");
  183. }
  184. // Check to see if there is an authenticated user in the session.
  185. $use_current_login = false;
  186. if(isset($_SESSION["authenticated_user_id"]) && (isset($_SESSION["app_unique_key"]) && $_SESSION["app_unique_key"] == $application_unique_key))
  187. {
  188. $use_current_login = true;
  189. }
  190. // Prevent loading Login again if there is an authenticated user in the session.
  191. if (isset($_SESSION["authenticated_user_id"]) && $module == 'Users' && $action == 'Login') {
  192. header("Location: index.php?action=$default_action&module=$default_module");
  193. }
  194. if($use_current_login){
  195. /*&Added to prevent fatal error before starting migration(5.0.4. patch ).
  196. //Start
  197. $arr=$adb->getColumnNames("vtiger_users");
  198. if(!in_array("internal_mailer", $arr))
  199. {
  200. $adb->pquery("alter table vtiger_users add column internal_mailer int(3) NOT NULL default '1'", array());
  201. $adb->pquery("alter table vtiger_users add column tagcloud_view int(1) default 1", array());
  202. }
  203. //End*/
  204. //getting the internal_mailer flag
  205. if(!isset($_SESSION['internal_mailer'])){
  206. $qry_res = $adb->pquery("select internal_mailer from vtiger_users where id=?", array($_SESSION["authenticated_user_id"]));
  207. $_SESSION['internal_mailer'] = $adb->query_result($qry_res,0,"internal_mailer");
  208. }
  209. $log->debug("We have an authenticated user id: ".$_SESSION["authenticated_user_id"]);
  210. }else if(isset($action) && isset($module) && $action=="Authenticate" && $module=="Users"){
  211. $log->debug("We are authenticating user now");
  212. }else{
  213. if($_REQUEST['action'] != 'Logout' && $_REQUEST['action'] != 'Login'){
  214. $_SESSION['lastpage'] = $_SERVER['argv'];
  215. }
  216. $log->debug("The current user does not have a session. Going to the login page");
  217. $action = "Login";
  218. $module = "Users";
  219. }
  220. $log->debug($_REQUEST);
  221. $skipHeaders=false;
  222. $skipFooters=false;
  223. $viewAttachment = false;
  224. $skipSecurityCheck= false;
  225. //echo $module;
  226. // echo $action;
  227. if(isset($action) && isset($module))
  228. {
  229. $log->info("About to take action ".$action);
  230. $log->debug("in $action");
  231. if(preg_match("/^Save/", $action) ||
  232. preg_match("/^Delete/", $action) ||
  233. preg_match("/^Choose/", $action) ||
  234. preg_match("/^Popup/", $action) ||
  235. preg_match("/^ChangePassword/", $action) ||
  236. preg_match("/^Authenticate/", $action) ||
  237. preg_match("/^Logout/", $action) ||
  238. preg_match("/^add2db/", $action) ||
  239. preg_match("/^result/", $action) ||
  240. preg_match("/^LeadConvertToEntities/", $action) ||
  241. preg_match("/^downloadfile/", $action) ||
  242. preg_match("/^massdelete/", $action) ||
  243. preg_match("/^updateLeadDBStatus/",$action) ||
  244. preg_match("/^AddCustomFieldToDB/", $action) ||
  245. preg_match("/^updateRole/",$action) ||
  246. preg_match("/^UserInfoUtil/",$action) ||
  247. preg_match("/^deleteRole/",$action) ||
  248. preg_match("/^UpdateComboValues/",$action) ||
  249. preg_match("/^fieldtypes/",$action) ||
  250. preg_match("/^app_ins/",$action) ||
  251. preg_match("/^minical/",$action) ||
  252. preg_match("/^minitimer/",$action) ||
  253. preg_match("/^app_del/",$action) ||
  254. preg_match("/^send_mail/",$action) ||
  255. preg_match("/^populatetemplate/",$action) ||
  256. preg_match("/^TemplateMerge/",$action) ||
  257. preg_match("/^testemailtemplateusage/",$action) ||
  258. preg_match("/^saveemailtemplate/",$action) ||
  259. preg_match("/^ProcessDuplicates/", $action ) ||
  260. preg_match("/^lastImport/", $action ) ||
  261. preg_match("/^lookupemailtemplate/",$action) ||
  262. preg_match("/^deletewordtemplate/",$action) ||
  263. preg_match("/^deleteemailtemplate/",$action) ||
  264. preg_match("/^CurrencyDelete/",$action) ||
  265. preg_match("/^deleteattachments/",$action) ||
  266. preg_match("/^MassDeleteUsers/",$action) ||
  267. preg_match("/^UpdateFieldLevelAccess/",$action) ||
  268. preg_match("/^UpdateDefaultFieldLevelAccess/",$action) ||
  269. preg_match("/^UpdateProfile/",$action) ||
  270. preg_match("/^updateRelations/",$action) ||
  271. preg_match("/^updateNotificationSchedulers/",$action) ||
  272. preg_match("/^Star/",$action) ||
  273. preg_match("/^addPbProductRelToDB/",$action) ||
  274. preg_match("/^UpdateListPrice/",$action) ||
  275. preg_match("/^PriceListPopup/",$action) ||
  276. preg_match("/^SalesOrderPopup/",$action) ||
  277. preg_match("/^CreatePDF/",$action) ||
  278. preg_match("/^CreateSOPDF/",$action) ||
  279. preg_match("/^CreateSNPDF/",$action) ||
  280. preg_match("/^redirect/",$action) ||
  281. preg_match("/^webmail/",$action) ||
  282. preg_match("/^left_main/",$action) ||
  283. preg_match("/^delete_message/",$action) ||
  284. preg_match("/^mime/",$action) ||
  285. preg_match("/^move_messages/",$action) ||
  286. preg_match("/^folders_create/",$action) ||
  287. preg_match("/^imap_general/",$action) ||
  288. preg_match("/^mime/",$action) ||
  289. preg_match("/^download/",$action) ||
  290. preg_match("/^about_us/",$action) ||
  291. preg_match("/^SendMailAction/",$action) ||
  292. preg_match("/^CreateXL/",$action) ||
  293. preg_match("/^savetermsandconditions/",$action) ||
  294. preg_match("/^home_rss/",$action) ||
  295. preg_match("/^ConvertAsFAQ/",$action) ||
  296. preg_match("/^Tickerdetail/",$action) ||
  297. preg_match("/^".$module."Ajax/",$action) ||
  298. preg_match("/^ActivityAjax/",$action) ||
  299. preg_match("/^chat/",$action) ||
  300. preg_match("/^vtchat/",$action) ||
  301. preg_match("/^updateCalendarSharing/",$action) ||
  302. preg_match("/^disable_sharing/",$action) ||
  303. preg_match("/^HeadLines/",$action) ||
  304. preg_match("/^TodoSave/",$action) ||
  305. preg_match("/^RecalculateSharingRules/",$action) ||
  306. (preg_match("/^body/",$action) && preg_match("/^Webmails/",$module)) ||
  307. (preg_match("/^dlAttachments/",$action) && preg_match("/^Webmails/",$module)) ||
  308. (preg_match("/^DetailView/",$action) && preg_match("/^Webmails/",$module)) ||
  309. preg_match("/^savewordtemplate/",$action) ||
  310. preg_match("/^mailmergedownloadfile/",$action) ||
  311. (preg_match("/^Webmails/",$module) && preg_match("/^get_img/",$action)) ||
  312. preg_match("/^download/",$action) ||
  313. preg_match("/^getListOfRecords/", $action) ||
  314. preg_match("/^AddBlockFieldToDB/", $action) ||
  315. preg_match("/^AddBlockToDB/", $action) ||
  316. preg_match("/^MassEditSave/", $action) ||
  317. preg_match("/^iCalExport/",$action) ||
  318. //pdf configurator
  319. preg_match("/^pdfconfig/",$action) ||
  320. preg_match("/^UpdatePDFSettings/",$action) ||
  321. preg_match("/^pdfsettings/",$action)
  322. )
  323. {
  324. $skipHeaders=true;
  325. //skip headers for all these invocations as they are mostly popups
  326. if(preg_match("/^Popup/", $action) ||
  327. preg_match("/^ChangePassword/", $action) ||
  328. //preg_match("/^Export/", $action) ||
  329. preg_match("/^downloadfile/", $action) ||
  330. preg_match("/^fieldtypes/",$action) ||
  331. preg_match("/^lookupemailtemplate/",$action) ||
  332. preg_match("/^about_us/",$action) ||
  333. preg_match("/^home_rss/",$action) ||
  334. preg_match("/^".$module."Ajax/",$action) ||
  335. preg_match("/^chat/",$action) ||
  336. preg_match("/^vtchat/",$action) ||
  337. preg_match("/^massdelete/", $action) ||
  338. preg_match("/^mailmergedownloadfile/",$action) || preg_match("/^get_img/",$action) ||
  339. preg_match("/^download/",$action) ||
  340. preg_match("/^ProcessDuplicates/", $action ) ||
  341. preg_match("/^lastImport/", $action ) ||
  342. preg_match("/^massdelete/", $action ) ||
  343. preg_match("/^getListOfRecords/", $action) ||
  344. preg_match("/^MassEditSave/", $action) ||
  345. preg_match("/^iCalExport/",$action) ||
  346. //pdf configurator
  347. preg_match("/^pdfconfig/",$action) ||
  348. preg_match("/^pdfsettings/", $action )
  349. )
  350. $skipFooters=true;
  351. //skip footers for all these invocations as they are mostly popups
  352. if(preg_match("/^downloadfile/", $action)
  353. || preg_match("/^fieldtypes/",$action)
  354. || preg_match("/^mailmergedownloadfile/",$action)
  355. || preg_match("/^get_img/",$action)
  356. || preg_match("/^MergeFieldLeads/", $action)
  357. || preg_match("/^MergeFieldContacts/", $action )
  358. || preg_match("/^MergeFieldAccounts/", $action )
  359. || preg_match("/^MergeFieldProducts/", $action )
  360. || preg_match("/^MergeFieldHelpDesk/", $action )
  361. || preg_match("/^MergeFieldPotentials/", $action )
  362. || preg_match("/^MergeFieldVendors/", $action )
  363. || preg_match("/^dlAttachments/", $action )
  364. || preg_match("/^iCalExport/", $action)
  365. )
  366. {
  367. $viewAttachment = true;
  368. }
  369. if(($action == ' Delete ') && (!$entityDel))
  370. {
  371. $skipHeaders=false;
  372. }
  373. }
  374. if($action == 'Save')
  375. {
  376. header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
  377. header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
  378. header( "Cache-Control: no-cache, must-revalidate" );
  379. header( "Pragma: no-cache" );
  380. }
  381. if($module == 'Users' || $module == 'Home' || $module == 'uploads')
  382. {
  383. $skipSecurityCheck=true;
  384. }
  385. if($action == 'UnifiedSearch') {
  386. $currentModuleFile = 'modules/Home/'.$action.'.php';
  387. } else {
  388. $currentModuleFile = 'modules/'.$module.'/'.$action.'.php';
  389. }
  390. $currentModule = $module;
  391. }
  392. elseif(isset($module))
  393. {
  394. $currentModule = $module;
  395. $currentModuleFile = $moduleDefaultFile[$currentModule];
  396. }
  397. else {
  398. // use $default_module and $default_action as set in config.php
  399. // Redirect to the correct module with the correct action. We need the URI to include these fields.
  400. header("Location: index.php?action=$default_action&module=$default_module");
  401. exit();
  402. }
  403. $log->info("current page is $currentModuleFile");
  404. $log->info("current module is $currentModule ");
  405. // for printing
  406. $module = (isset($_REQUEST['module'])) ? vtlib_purify($_REQUEST['module']) : "";
  407. $action = (isset($_REQUEST['action'])) ? vtlib_purify($_REQUEST['action']) : "";
  408. $record = (isset($_REQUEST['record'])) ? vtlib_purify($_REQUEST['record']) : "";
  409. $lang_crm = (isset($_SESSION['authenticated_user_language'])) ? $_SESSION['authenticated_user_language'] : "";
  410. $GLOBALS['request_string'] = "&module=$module&action=$action&record=$record&lang_crm=$lang_crm";
  411. $current_user = new Users();
  412. if($use_current_login)
  413. {
  414. //$result = $current_user->retrieve($_SESSION['authenticated_user_id']);
  415. //getting the current user info from flat file
  416. $result = $current_user->retrieveCurrentUserInfoFromFile($_SESSION['authenticated_user_id']);
  417. if($result == null)
  418. {
  419. session_destroy();
  420. header("Location: index.php?action=Login&module=Users");
  421. }
  422. $moduleList = getPermittedModuleNames();
  423. foreach ($moduleList as $mod) {
  424. $moduleDefaultFile[$mod] = "modules/".$currentModule."/index.php";
  425. }
  426. //auditing
  427. require_once('user_privileges/audit_trail.php');
  428. if($audit_trail == 'true')
  429. {
  430. if($record == '')
  431. $auditrecord = '';
  432. else
  433. $auditrecord = $record;
  434. /* Skip audit trial log for special request types */
  435. $skip_auditing = false;
  436. if($action == 'chat') {
  437. $skip_auditing = true;
  438. } else if(($action == 'ActivityReminderCallbackAjax' || $_REQUEST['file'] == 'ActivityReminderCallbackAjax') && $module == 'Calendar') {
  439. $skip_auditing = true;
  440. } else if(($action == 'TraceIncomingCall' || $_REQUEST['file'] == 'TraceIncomingCall') && $module == 'PBXManager') {
  441. $skip_auditing = true;
  442. }
  443. /* END */
  444. if (!$skip_auditing) {
  445. $date_var = $adb->formatDate(date('Y-m-d H:i:s'), true);
  446. $query = "insert into vtiger_audit_trial values(?,?,?,?,?,?)";
  447. $qparams = array($adb->getUniqueID('vtiger_audit_trial'), $current_user->id, $module, $action, $auditrecord, $date_var);
  448. $adb->pquery($query, $qparams);
  449. }
  450. }
  451. $log->debug('Current user is: '.$current_user->user_name);
  452. }
  453. if(isset($_SESSION['vtiger_authenticated_user_theme']) && $_SESSION['vtiger_authenticated_user_theme'] != '')
  454. {
  455. $theme = $_SESSION['vtiger_authenticated_user_theme'];
  456. }
  457. else
  458. {
  459. $theme = $default_theme;
  460. }
  461. $log->debug('Current theme is: '.$theme);
  462. //Used for current record focus
  463. $focus = "";
  464. // if the language is not set yet, then set it to the default language.
  465. if(isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '')
  466. {
  467. $current_language = $_SESSION['authenticated_user_language'];
  468. }
  469. else
  470. {
  471. $current_language = $default_language;
  472. }
  473. $log->debug('current_language is: '.$current_language);
  474. //set module and application string arrays based upon selected language
  475. $app_currency_strings = return_app_currency_strings_language($current_language);
  476. $app_strings = return_application_language($current_language);
  477. $app_list_strings = return_app_list_strings_language($current_language);
  478. $mod_strings = return_module_language($current_language, $currentModule);
  479. //If DetailView, set focus to record passed in
  480. if($action == "DetailView")
  481. {
  482. if(!isset($_REQUEST['record']))
  483. die("A record number must be specified to view details.");
  484. // If we are going to a detail form, load up the record now.
  485. // Use the record to track the viewing.
  486. // todo - Have a record of modules and thier primary object names.
  487. //Getting the actual module
  488. switch($currentModule)
  489. {
  490. case 'Webmails':
  491. //No need to create a webmail object here
  492. break;
  493. default:
  494. $focus = CRMEntity::getInstance($currentModule);
  495. break;
  496. }
  497. if(isset($_REQUEST['record']) && $_REQUEST['record']!='' && $_REQUEST["module"] != "Webmails" && $current_user->id != '')
  498. {
  499. // Only track a viewing if the record was retrieved.
  500. $focus->track_view($current_user->id, $currentModule,$_REQUEST['record']);
  501. }
  502. }
  503. // set user, theme and language cookies so that login screen defaults to last values
  504. if (isset($_SESSION['authenticated_user_id'])) {
  505. $log->debug("setting cookie ck_login_id_vtiger to ".$_SESSION['authenticated_user_id']);
  506. setcookie('ck_login_id_vtiger', $_SESSION['authenticated_user_id']);
  507. }
  508. if (isset($_SESSION['vtiger_authenticated_user_theme'])) {
  509. $log->debug("setting cookie ck_login_theme_vtiger to ".$_SESSION['vtiger_authenticated_user_theme']);
  510. setcookie('ck_login_theme_vtiger', $_SESSION['vtiger_authenticated_user_theme']);
  511. }
  512. if (isset($_SESSION['authenticated_user_language'])) {
  513. $log->debug("setting cookie ck_login_language_vtiger to ".$_SESSION['authenticated_user_language']);
  514. setcookie('ck_login_language_vtiger', $_SESSION['authenticated_user_language']);
  515. }
  516. if($_REQUEST['module'] == 'Documents' && $action == 'DownloadFile')
  517. {
  518. include('modules/Documents/DownloadFile.php');
  519. exit;
  520. }
  521. //skip headers for popups, deleting, saving, importing and other actions
  522. if(!$skipHeaders) {
  523. $log->debug("including headers");
  524. if($use_current_login)
  525. {
  526. if(isset($_REQUEST['category']) && $_REQUEST['category'] !='')
  527. {
  528. $category = vtlib_purify($_REQUEST['category']);
  529. }
  530. else
  531. {
  532. $category = getParentTabFromModule($currentModule);
  533. }
  534. include('themes/'.$theme.'/header.php');
  535. }
  536. else
  537. include('themes/'.$theme.'/loginheader.php');
  538. if(isset($_SESSION['administrator_error']))
  539. {
  540. // only print DB errors once otherwise they will still look broken after they are fixed.
  541. // Only print the errors for admin users.
  542. if(is_admin($current_user))
  543. echo $_SESSION['administrator_error'];
  544. unset($_SESSION['administrator_error']);
  545. }
  546. echo "<!-- startscrmprint -->";
  547. }
  548. else {
  549. $log->debug("skipping headers");
  550. }
  551. //fetch the permission set from session and search it for the requisite data
  552. if(isset($_SESSION['vtiger_authenticated_user_theme']) && $_SESSION['vtiger_authenticated_user_theme'] != '')
  553. {
  554. $theme = $_SESSION['vtiger_authenticated_user_theme'];
  555. }
  556. else
  557. {
  558. $theme = $default_theme;
  559. }
  560. //logging the security Information
  561. $seclog->debug('######## Module --> '.$module.' :: Action --> '.$action.' :: UserID --> '.$current_user->id.' :: RecordID --> '.$record.' #######');
  562. if(!$skipSecurityCheck)
  563. {
  564. require_once('include/utils/UserInfoUtil.php');
  565. if(preg_match('/Ajax/',$action)) {
  566. if($_REQUEST['ajxaction'] == 'LOADRELATEDLIST'){
  567. $now_action = 'DetailView';
  568. } else {
  569. $now_action=vtlib_purify($_REQUEST['file']);
  570. }
  571. } else {
  572. $now_action=$action;
  573. }
  574. if(isset($_REQUEST['record']) && $_REQUEST['record'] != '')
  575. {
  576. $display = isPermitted($module,$now_action,$_REQUEST['record']);
  577. }
  578. else
  579. {
  580. $display = isPermitted($module,$now_action);
  581. }
  582. $seclog->debug('########### Pemitted ---> '.$display.' ##############');
  583. }
  584. else
  585. {
  586. $seclog->debug('########### Pemitted ---> yes ##############');
  587. }
  588. if($display == "no")
  589. {
  590. echo "<link rel='stylesheet' type='text/css' href='themes/$theme/style.css'>";
  591. echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
  592. echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>
  593. <table border='0' cellpadding='5' cellspacing='0' width='98%'>
  594. <tbody><tr>
  595. <td rowspan='2' width='11%'><img src='". vtiger_imageurl('denied.gif', $theme) . "' ></td>
  596. <td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span class='genHeaderSmall'>$app_strings[LBL_PERMISSION]</span></td>
  597. </tr>
  598. <tr>
  599. <td class='small' align='right' nowrap='nowrap'>
  600. <a href='javascript:window.history.back();'>$app_strings[LBL_GO_BACK]</a><br> </td>
  601. </tr>
  602. </tbody></table>
  603. </div>";
  604. echo "</td></tr></table>";
  605. }
  606. // vtlib customization: Check if module has been de-activated
  607. else if(!vtlib_isModuleActive($currentModule)) {
  608. echo "<link rel='stylesheet' type='text/css' href='themes/$theme/style.css'>";
  609. echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
  610. echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>
  611. <table border='0' cellpadding='5' cellspacing='0' width='98%'>
  612. <tbody><tr>
  613. <td rowspan='2' width='11%'><img src='". vtiger_imageurl('denied.gif', $theme) . "' ></td>
  614. <td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span class='genHeaderSmall'>$currentModule $app_strings[VTLIB_MOD_NOT_ACTIVE]</span></td>
  615. </tr>
  616. <tr>
  617. <td class='small' align='right' nowrap='nowrap'>
  618. <a href='javascript:window.history.back();'>$app_strings[LBL_GO_BACK]</a><br> </td>
  619. </tr>
  620. </tbody></table>
  621. </div>";
  622. echo "</td></tr></table>";
  623. }
  624. // END
  625. else
  626. {
  627. include($currentModuleFile);
  628. }
  629. if((!$viewAttachment) && (!$viewAttachment && $action != 'home_rss' && $action != $module."Ajax" && $action != "chat" && $action != 'massdelete' && $action != "body") )
  630. {
  631. echo "<!-- stopscrmprint -->";
  632. }
  633. //added to get the theme . This is a bad fix as we need to know where the problem lies yet
  634. if(isset($_SESSION['vtiger_authenticated_user_theme']) && $_SESSION['vtiger_authenticated_user_theme'] != '')
  635. {
  636. $theme = $_SESSION['vtiger_authenticated_user_theme'];
  637. }
  638. else
  639. {
  640. $theme = $default_theme;
  641. }
  642. $Ajx_module= $module;
  643. if($module == 'Events')
  644. $Ajx_module = 'Calendar';
  645. if((!$viewAttachment) && (!$viewAttachment && $action != 'home_rss') && $action != 'Tickerdetail' && $action != $Ajx_module."Ajax" && $action != "chat" && $action != "HeadLines" && $action != 'massdelete' && $action != "DashboardAjax" && $action != "ActivityAjax")
  646. {
  647. // Under the SPL you do not have the right to remove this copyright statement.
  648. $copyrightstatement="<style>
  649. .bggray
  650. {
  651. background-color: #dfdfdf;
  652. }
  653. .bgwhite
  654. {
  655. background-color: #FFFFFF;
  656. }
  657. .copy
  658. {
  659. font-size:9px;
  660. font-family: Verdana, Arial, Helvetica, Sans-serif;
  661. }
  662. </style>
  663. <script language=javascript>
  664. function LogOut(e)
  665. {
  666. var nav4 = window.Event ? true : false;
  667. var iX,iY;
  668. if (nav4)
  669. {
  670. iX = e.pageX;
  671. iY = e.pageY;
  672. }
  673. else
  674. {
  675. iX = event.clientX + document.body.scrollLeft;
  676. iY = event.clientY + document.body.scrollTop;
  677. }
  678. if (iX <= 30 && iY < 0 )
  679. {
  680. w=window.open(\"index.php?action=Logout&module=Users\");
  681. w.close();
  682. }
  683. }
  684. //window.onunload=LogOut
  685. </script>
  686. ";
  687. if((!$skipFooters) && $action != "about_us" && $action != "vtchat" && $action != "ChangePassword" && $action != "body" && $action != $module."Ajax" && $action!='Popup' && $action != 'ImportStep3' && $action != 'ActivityAjax' && $action != 'getListOfRecords')
  688. {
  689. echo $copyrightstatement;
  690. // Status tracking
  691. $statimage = '';
  692. if($currentModule == 'Users' && empty($current_user->id)) {
  693. global $disable_stats_tracking;
  694. if(isset($disable_stats_tracking) && !empty($disable_stats_tracking)) {
  695. $statimage = "";
  696. } else {
  697. $statimage = "<img src='http://stats.vtiger.com/stats.php?uid=$application_unique_key&v=$vtiger_current_version&type=U'
  698. alt='|' title='' border=0 width='1px' height='1px'>";
  699. }
  700. }
  701. // END
  702. echo "<script language = 'JavaScript' type='text/javascript' src = 'include/js/popup.js'></script>";
  703. echo "<br><br><br><table border=0 cellspacing=0 cellpadding=5 width=100% class=settingsSelectedUI >";
  704. echo "<tr><td class=small align=left><span style='color: rgb(153, 153, 153);'>vtiger CRM $vtiger_current_version</span></td>";
  705. echo "<td class=small align=right><span style='color: rgb(153, 153, 153);'>&copy; 2004-".date('Y')." <a href='http://www.vtiger.com' target='_blank'>vtiger.com</a> | <a href='javascript:mypopup()'>".$app_strings['LNK_READ_LICENSE']."</a> | <a href='http://www.vtiger.com/products/crm/privacy_policy.html' target='_blank'>".getTranslatedString('LNK_PRIVACY_POLICY')."</a></span> $statimage</td></tr></table>";
  706. // echo "<table align='center'><tr><td align='center'>";
  707. // Under the Sugar Public License referenced above, you are required to leave in all copyright statements
  708. // in both the code and end-user application.
  709. // if($calculate_response_time)
  710. // {
  711. // $endTime = microtime();
  712. // $deltaTime = microtime_diff($startTime, $endTime);
  713. // echo('&nbsp;Server response time: '.$deltaTime.' seconds.');
  714. // }
  715. // echo "</td></tr></table>\n";
  716. }
  717. if(($action != 'mytkt_rss') && ($action != 'home_rss') && ($action != $module."Ajax") && ($action != "body") && ($action != 'ActivityAjax'))
  718. {
  719. ?>
  720. <script>
  721. var userDateFormat = "<?php echo $current_user->date_format ?>";
  722. var default_charset = "<?php echo $default_charset; ?>";
  723. </script>
  724. <?php
  725. }
  726. // ActivityReminder Customization for callback
  727. if(!$skipFooters) {
  728. if($current_user->id!=NULL && isPermitted('Calendar','index') == 'yes' &&
  729. vtlib_isModuleActive('Calendar')) {
  730. echo "<script type='text/javascript'>if(typeof(ActivityReminderCallback) != ".
  731. "'undefined') ";
  732. $cur_time = time();
  733. $reminder_interval_reset = (($_SESSION['last_reminder_check_time'] +
  734. $_SESSION['next_reminder_interval']) - $cur_time) * 1000;
  735. if(isset($_SESSION['last_reminder_check_time']) && $reminder_interval_reset > 0){
  736. echo "window.setTimeout(function(){
  737. ActivityReminderCallback();
  738. },$reminder_interval_reset);";
  739. } else {
  740. echo "ActivityReminderCallback();";
  741. }
  742. echo "</script>";
  743. }
  744. }
  745. // End
  746. if((!$skipFooters) && ($action != "body") && ($action != $module."Ajax") && ($action != "ActivityAjax"))
  747. include('themes/'.$theme.'/footer.php');
  748. }
  749. ?>