/** * Constructor */ function __construct($dbtype = '', $host = '', $dbname = '', $username = '', $passwd = '') { $this->log = LoggerManager::getLogger('DB'); $this->resetSettings($dbtype, $host, $dbname, $username, $passwd); // Initialize performance parameters $this->isdb_default_utf8_charset = PerformancePrefs::getBoolean('DB_DEFAULT_CHARSET_UTF8'); if (!isset($this->dbType)) { $this->log('Database connect : DBType not specified', 'error'); return; } $this->setDieOnError(SysDebug::get('SQL_DIE_ON_ERROR')); $this->connect(); }
/** * Constructor */ function __construct($dbtype = '', $host = '', $dbname = '', $username = '', $passwd = '') { $this->log = LoggerManager::getLogger('DB'); $this->loadDBConfig($dbtype, $host, $dbname, $username, $passwd); // Initialize performance parameters $this->isdb_default_utf8_charset = PerformancePrefs::getBoolean('DB_DEFAULT_CHARSET_UTF8'); if (!isset($this->dbType) || !isset($this->dbHostName) || !isset($this->dbName)) { $this->log('No configuration for the database connection', 'fatal'); return false; } $this->setDieOnError(SysDebug::get('SQL_DIE_ON_ERROR')); $this->connect(); }
/** * Constructor - Sets the templateDir and compileDir for the Smarty files * @param <String> - $media Layout/Media name */ function __construct($media = '') { parent::__construct(); $THISDIR = dirname(__FILE__); $templatesDir = ''; $compileDir = ''; $templateDir = []; if (!empty($media)) { self::$currentLayout = $media; $customTemplatesDir = $THISDIR . '/../../custom/layouts/' . $media; $templateDir[] = $THISDIR . '/../../layouts/' . $media; $compileDir = $THISDIR . '/../../cache/templates_c/' . $media; } $defaultLayout = vglobal('defaultLayout'); if ($defaultLayout && is_file(vglobal('root_directory') . '/layouts/' . $defaultLayout)) { $templateDir[] = $THISDIR . '/../../layouts/' . $defaultLayout; } if (empty($templatesDir) || !file_exists($templatesDir)) { self::$currentLayout = self::getDefaultLayoutName(); $templateDir[] = $THISDIR . '/../../custom/layouts/' . self::getDefaultLayoutName(); $templateDir[] = $THISDIR . '/../../layouts/' . self::getDefaultLayoutName(); $compileDir = $THISDIR . '/../../cache/templates_c/' . self::getDefaultLayoutName(); } if (!file_exists($compileDir)) { mkdir($compileDir, 0777, true); } $this->setTemplateDir($templateDir); $this->setCompileDir($compileDir); self::$debugViewer = SysDebug::get('DEBUG_VIEWER'); // FOR SECURITY // Escape all {$variable} to overcome XSS // We need to use {$variable nofilter} to overcome double escaping // TODO: Until we review the use disabled. //$this->registerFilter('variable', array($this, 'safeHtmlFilter')); // FOR DEBUGGING: We need to have this only once. static $debugViewerURI = false; if (self::$debugViewer && $debugViewerURI === false) { $debugViewerURI = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); if (!empty($_POST)) { $debugViewerURI .= '?' . http_build_query($_POST); } else { $debugViewerURI = $_SERVER['REQUEST_URI']; } $this->log("URI: {$debugViewerURI}, TYPE: " . $_SERVER['REQUEST_METHOD']); } }
function checkError($message, $dieOnError = false, $query = false, $params = false) { if ($this->hasActiveTransaction) { $this->rollbackTransaction(); } if ($this->dieOnError || $dieOnError) { if (SysDebug::get('DISPLAY_DEBUG_BACKTRACE')) { $queryInfo = ''; if ($query !== false) { $queryInfo .= 'Query: ' . $query . PHP_EOL; } if ($params !== false && $params != NULL) { $queryInfo .= 'Params: ' . implode(',', $params) . PHP_EOL; } $backtrace = Vtiger_Functions::getBacktrace(); $trace = '<pre>' . $queryInfo . $backtrace . '</pre>'; } Vtiger_Functions::throwNewException('Database ERROR: ' . PHP_EOL . $message . PHP_EOL . $trace); } }
function process(Vtiger_Request $request) { vglobal('log', LoggerManager::getLogger('System')); Vtiger_Session::init(); $forceSSL = vglobal('forceSSL'); if ($forceSSL && !Vtiger_Functions::getBrowserInfo()->https) { header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"); } // Better place this here as session get initiated //skipping the csrf checking for the forgot(reset) password $csrfProtection = vglobal('csrfProtection'); if ($csrfProtection) { if ($request->get('mode') != 'reset' && $request->get('action') != 'Login') { require_once 'libraries/csrf-magic/csrf-magic.php'; } } // TODO - Get rid of global variable $current_user // common utils api called, depend on this variable right now $currentUser = $this->getLogin(); vglobal('current_user', $currentUser); $currentLanguage = Vtiger_Language_Handler::getLanguage(); vglobal('current_language', $currentLanguage); $module = $request->getModule(); $qualifiedModuleName = $request->getModule(false); if ($currentUser && $qualifiedModuleName) { $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $qualifiedModuleName); vglobal('mod_strings', $moduleLanguageStrings['languageStrings']); } if ($currentUser) { $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage); vglobal('app_strings', $moduleLanguageStrings['languageStrings']); } $view = $request->get('view'); $action = $request->get('action'); $response = false; try { if ($this->isInstalled() === false && $module != 'Install') { header('Location:install/Install.php'); exit; } if (empty($module)) { if ($this->hasLogin()) { $defaultModule = vglobal('default_module'); if (!empty($defaultModule) && $defaultModule != 'Home') { $module = $defaultModule; $qualifiedModuleName = $defaultModule; $view = 'List'; if ($module == 'Calendar') { // To load MyCalendar instead of list view for calendar //TODO: see if it has to enhanced and get the default view from module model $view = 'Calendar'; } } else { $module = 'Home'; $qualifiedModuleName = 'Home'; $view = 'DashBoard'; } } else { $module = 'Users'; $qualifiedModuleName = 'Settings:Users'; $view = 'Login'; } $request->set('module', $module); $request->set('view', $view); } if (!empty($action)) { $componentType = 'Action'; $componentName = $action; } else { $componentType = 'View'; if (empty($view)) { $view = 'Index'; } $componentName = $view; } $handlerClass = Vtiger_Loader::getComponentClassName($componentType, $componentName, $qualifiedModuleName); $handler = new $handlerClass(); if ($handler) { vglobal('currentModule', $module); $csrfProtection = vglobal('csrfProtection'); if ($csrfProtection) { // Ensure handler validates the request $handler->validateRequest($request); } if ($handler->loginRequired()) { $this->checkLogin($request); } //TODO : Need to review the design as there can potential security threat $skipList = array('Users', 'Home', 'CustomView', 'Import', 'Export', 'Inventory', 'Vtiger', 'Migration', 'Install'); if (!in_array($module, $skipList) && stripos($qualifiedModuleName, 'Settings') === false) { $this->triggerCheckPermission($handler, $request); } // Every settings page handler should implement this method if (stripos($qualifiedModuleName, 'Settings') === 0 || $module == 'Users') { $handler->checkPermission($request); } $notPermittedModules = array('ModComments', 'Integration', 'DashBoard'); if (in_array($module, $notPermittedModules) && $view == 'List') { header('Location:index.php?module=Home&view=DashBoard'); } $this->triggerPreProcess($handler, $request); $response = $handler->process($request); $this->triggerPostProcess($handler, $request); } else { throw new AppException(vtranslate('LBL_HANDLER_NOT_FOUND')); } } catch (AppException $e) { $log = vglobal('log'); if (!$request->isAjax()) { // Log for developement. $log->error($e->getMessage() . ' => ' . $e->getFile() . ':' . $e->getLine()); Vtiger_Functions::throwNewException($e->getMessage()); } else { $response = new Vtiger_Response(); $response->setEmitType(Vtiger_Response::$EMIT_JSON); $response->setError($e->getMessage()); $log->error($e->getMessage() . ' => ' . $e->getFile() . ':' . $e->getLine()); } if (SysDebug::get('DISPLAY_DEBUG_BACKTRACE')) { die($e->getTraceAsString()); } } if ($response) { $response->emit(); } }
$directory->getRootChild(); $nodes[] = $directory; } // The object tree needs in turn to be passed to the server class $server = new Yeti\DAV_Server($nodes); $server->setBaseUri($baseUri); $server->debugExceptions = SysDebug::get('DAV_DEBUG_EXCEPTIONS'); // Plugins $server->addPlugin(new Sabre\DAV\Auth\Plugin($authBackend, 'YetiDAV')); $server->addPlugin(new Sabre\DAVACL\Plugin()); $server->addPlugin(new Sabre\DAV\Sync\Plugin()); if ($enableBrowser) { $server->addPlugin(new Sabre\DAV\Browser\Plugin()); // Automatically guess (some) contenttypes, based on extesion $server->addPlugin(new Sabre\DAV\Browser\GuessContentType()); } if ($enableCardDAV) { //CardDav integration $server->addPlugin(new Sabre\CardDAV\Plugin()); } if ($enableCalDAV) { //CalDAV integration $server->addPlugin(new Sabre\CalDAV\Plugin()); $server->addPlugin(new Sabre\CalDAV\Subscriptions\Plugin()); $server->addPlugin(new Sabre\CalDAV\Schedule\Plugin()); } if (SysDebug::get('DAV_DEBUG_PLUGIN')) { $server->addPlugin(new Yeti\Debug()); } // And off we go! $server->exec();
function checkError($message, $dieOnError = false) { if ($this->hasActiveTransaction) { $this->rollbackTransaction(); } if ($this->dieOnError || $dieOnError) { if (SysDebug::get('DISPLAY_DEBUG_BACKTRACE')) { ob_start(); debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $trace = '<pre>' . ob_get_contents() . '</pre>'; ob_end_clean(); } die('Database ERROR: ' . $message . $trace); } }
function checkError($message, $dieOnError = false, $query = false, $params = false) { if ($this->hasActiveTransaction) { $this->rollbackTransaction(); } if ($this->dieOnError || $dieOnError) { if (SysDebug::get('DISPLAY_DEBUG_BACKTRACE')) { ob_start(); debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $queryInfo = ''; if ($query !== false) { $queryInfo .= 'Query: ' . $query . PHP_EOL; } if ($params !== false && $params != NULL) { $queryInfo .= 'Params: ' . implode(',', $params) . PHP_EOL; } $trace = '<pre>' . $queryInfo . ob_get_contents() . '</pre>'; ob_end_clean(); } die('Database ERROR: ' . $message . $trace); } }
/** * Constructor */ function PearDatabase($dbtype = '', $host = '', $dbname = '', $username = '', $passwd = '') { global $currentModule; $this->log = LoggerManager::getLogger('PearDatabase_' . $currentModule); $this->resetSettings($dbtype, $host, $dbname, $username, $passwd); // Initialize performance parameters $this->isdb_default_utf8_charset = PerformancePrefs::getBoolean('DB_DEFAULT_CHARSET_UTF8'); // END if (!isset($this->dbType)) { $this->println("ADODB Connect : DBType not specified"); return; } $this->setDieOnError(SysDebug::get('SQL_DIE_ON_ERROR')); }
/** * Initialize new Smarty object */ public function __construct() { // selfpointer needed by some other class methods $this->smarty = $this; if (is_callable('mb_internal_encoding')) { mb_internal_encoding(Smarty::$_CHARSET); } $this->start_time = microtime(true); // set default dirs $this->setTemplateDir('.' . DS . 'templates' . DS)->setCompileDir('.' . DS . 'templates_c' . DS)->setPluginsDir(SMARTY_PLUGINS_DIR)->setCacheDir('.' . DS . 'cache' . DS)->setConfigDir('.' . DS . 'configs' . DS); $this->debug_tpl = 'file:' . dirname(__FILE__) . '/debug.tpl'; if (isset($_SERVER['SCRIPT_NAME'])) { $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']); } $this->debugging = SysDebug::get('DISPLAY_DEBUG_VIEWER'); // YetiForce Sp. z o.o. // }