[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /* +*********************************************************************************** 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * *********************************************************************************** */ 10 11 class Install_ConfigFileUtils_Model { 12 13 private $rootDirectory; 14 private $dbHostname; 15 private $dbPort; 16 private $dbUsername; 17 private $dbPassword; 18 private $dbName; 19 private $dbType; 20 private $siteUrl; 21 private $cacheDir; 22 private $vtCharset = 'UTF-8'; 23 private $currencyName; 24 private $adminEmail; 25 26 function Install_ConfigFileUtils_Model($configFileParameters) { 27 if (isset($configFileParameters['root_directory'])) 28 $this->rootDirectory = $configFileParameters['root_directory']; 29 30 if (isset($configFileParameters['db_hostname'])) { 31 if(strpos($configFileParameters['db_hostname'], ":")) { 32 list($this->dbHostname,$this->dbPort) = explode(":",$configFileParameters['db_hostname']); 33 } else { 34 $this->dbHostname = $configFileParameters['db_hostname']; 35 } 36 } 37 38 if (isset($configFileParameters['db_username'])) $this->dbUsername = $configFileParameters['db_username']; 39 if (isset($configFileParameters['db_password'])) $this->dbPassword = $configFileParameters['db_password']; 40 if (isset($configFileParameters['db_name'])) $this->dbName = $configFileParameters['db_name']; 41 if (isset($configFileParameters['db_type'])) $this->dbType = $configFileParameters['db_type']; 42 if (isset($configFileParameters['site_URL'])) $this->siteUrl = $configFileParameters['site_URL']; 43 if (isset($configFileParameters['admin_email'])) $this->adminEmail = $configFileParameters['admin_email']; 44 if (isset($configFileParameters['currency_name'])) $this->currencyName = $configFileParameters['currency_name']; 45 if (isset($configFileParameters['vt_charset'])) $this->vtCharset = $configFileParameters['vt_charset']; 46 47 // update default port 48 if ($this->dbPort == '') $this->dbPort = self::getDbDefaultPort($this->dbType); 49 50 $this->cacheDir = 'cache/'; 51 } 52 53 static function getDbDefaultPort($dbType) { 54 if(Install_Utils_Model::isMySQL($dbType)) { 55 return "3306"; 56 } 57 } 58 59 function createConfigFile() { 60 /* open template configuration file read only */ 61 $templateFilename = 'config.template.php'; 62 $templateHandle = fopen($templateFilename, "r"); 63 if($templateHandle) { 64 /* open include configuration file write only */ 65 $includeFilename = 'config.inc.php'; 66 $includeHandle = fopen($includeFilename, "w"); 67 if($includeHandle) { 68 while (!feof($templateHandle)) { 69 $buffer = fgets($templateHandle); 70 71 /* replace _DBC_ variable */ 72 $buffer = str_replace( "_DBC_SERVER_", $this->dbHostname, $buffer); 73 $buffer = str_replace( "_DBC_PORT_", $this->dbPort, $buffer); 74 $buffer = str_replace( "_DBC_USER_", $this->dbUsername, $buffer); 75 $buffer = str_replace( "_DBC_PASS_", $this->dbPassword, $buffer); 76 $buffer = str_replace( "_DBC_NAME_", $this->dbName, $buffer); 77 $buffer = str_replace( "_DBC_TYPE_", $this->dbType, $buffer); 78 79 $buffer = str_replace( "_SITE_URL_", $this->siteUrl, $buffer); 80 81 /* replace dir variable */ 82 $buffer = str_replace( "_VT_ROOTDIR_", $this->rootDirectory, $buffer); 83 $buffer = str_replace( "_VT_CACHEDIR_", $this->cacheDir, $buffer); 84 $buffer = str_replace( "_VT_TMPDIR_", $this->cacheDir."images/", $buffer); 85 $buffer = str_replace( "_VT_UPLOADDIR_", $this->cacheDir."upload/", $buffer); 86 $buffer = str_replace( "_DB_STAT_", "true", $buffer); 87 88 /* replace charset variable */ 89 $buffer = str_replace( "_VT_CHARSET_", $this->vtCharset, $buffer); 90 91 /* replace master currency variable */ 92 $buffer = str_replace( "_MASTER_CURRENCY_", $this->currencyName, $buffer); 93 94 /* replace the application unique key variable */ 95 $buffer = str_replace( "_VT_APP_UNIQKEY_", md5(time() + rand(1,9999999) + md5($this->rootDirectory)) , $buffer); 96 97 /* replace support email variable */ 98 $buffer = str_replace( "_USER_SUPPORT_EMAIL_", $this->adminEmail, $buffer); 99 100 fwrite($includeHandle, $buffer); 101 } 102 fclose($includeHandle); 103 } 104 fclose($templateHandle); 105 } 106 107 if ($templateHandle && $includeHandle) { 108 return true; 109 } 110 return false; 111 } 112 113 function getConfigFileContents() { 114 115 $configFileContents = "<?php 116 /* +*********************************************************************************** 117 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 118 * (License); You may not use this file except in compliance with the License 119 * The Original Code is: vtiger CRM Open Source 120 * The Initial Developer of the Original Code is vtiger. 121 * Portions created by vtiger are Copyright (C) vtiger. 122 * All Rights Reserved. 123 * *********************************************************************************** */ 124 125 include ('vtigerversion.php'); 126 127 // more than 8MB memory needed for graphics 128 // memory limit default value = 64M 129 ini_set('memory_limit','64M'); 130 131 // helpdesk support email id and support name (Example: '[email protected]' and 'vtiger support') 132 \$HELPDESK_SUPPORT_EMAIL_ID = '{$this->adminEmail}'; 133 \$HELPDESK_SUPPORT_NAME = 'your-support name'; 134 \$HELPDESK_SUPPORT_EMAIL_REPLY_ID = \$HELPDESK_SUPPORT_EMAIL_ID; 135 136 \$dbconfig['db_server'] = '{$this->dbHostname}'; 137 \$dbconfig['db_port'] = ':{$this->dbPort}'; 138 \$dbconfig['db_username'] = '{$this->dbUsername}'; 139 \$dbconfig['db_password'] = '{$this->dbPassword}'; 140 \$dbconfig['db_name'] = '{$this->dbName}'; 141 \$dbconfig['db_type'] = '{$this->dbType}'; 142 \$dbconfig['db_status'] = 'true'; 143 144 // TODO: test if port is empty 145 // TODO: set db_hostname dependending on db_type 146 \$dbconfig['db_hostname'] = \$dbconfig['db_server'].\$dbconfig['db_port']; 147 148 // log_sql default value = false 149 \$dbconfig['log_sql'] = false; 150 151 // persistent default value = true 152 \$dbconfigoption['persistent'] = true; 153 154 // autofree default value = false 155 \$dbconfigoption['autofree'] = false; 156 157 // debug default value = 0 158 \$dbconfigoption['debug'] = 0; 159 160 // seqname_format default value = '%s_seq' 161 \$dbconfigoption['seqname_format'] = '%s_seq'; 162 163 // portability default value = 0 164 \$dbconfigoption['portability'] = 0; 165 166 // ssl default value = false 167 \$dbconfigoption['ssl'] = false; 168 169 \$host_name = \$dbconfig['db_hostname']; 170 171 \$site_URL = '{$this->siteUrl}'; 172 173 // root directory path 174 \$root_directory = '{$this->rootDirectory}'; 175 176 // cache direcory path 177 \$cache_dir = '{$this->cacheDir}'; 178 179 // tmp_dir default value prepended by cache_dir = images/ 180 \$tmp_dir = '{$this->cacheDir}images/'; 181 182 // import_dir default value prepended by cache_dir = import/ 183 \$import_dir = 'cache/import/'; 184 185 // upload_dir default value prepended by cache_dir = upload/ 186 \$upload_dir = '{$this->cacheDir}upload/'; 187 188 // maximum file size for uploaded files in bytes also used when uploading import files 189 // upload_maxsize default value = 3000000 190 \$upload_maxsize = 3000000; 191 192 // flag to allow export functionality 193 // 'all' to allow anyone to use exports 194 // 'admin' to only allow admins to export 195 // 'none' to block exports completely 196 // allow_exports default value = all 197 \$allow_exports = 'all'; 198 199 // files with one of these extensions will have '.txt' appended to their filename on upload 200 \$upload_badext = array('php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'exe', 'bin', 'bat', 'sh', 'dll', 'phps', 'phtml', 'xhtml', 'rb', 'msi', 'jsp', 'shtml', 'sth', 'shtm'); 201 202 // full path to include directory including the trailing slash 203 // includeDirectory default value = \$root_directory..'include/ 204 \$includeDirectory = \$root_directory.'include/'; 205 206 // list_max_entries_per_page default value = 20 207 \$list_max_entries_per_page = '20'; 208 209 // limitpage_navigation default value = 5 210 \$limitpage_navigation = '5'; 211 212 // history_max_viewed default value = 5 213 \$history_max_viewed = '5'; 214 215 // default_module default value = Home 216 \$default_module = 'Home'; 217 218 // default_action default value = index 219 \$default_action = 'index'; 220 221 // set default theme 222 // default_theme default value = blue 223 \$default_theme = 'softed'; 224 225 // show or hide time to compose each page 226 // calculate_response_time default value = true 227 \$calculate_response_time = true; 228 229 // default text that is placed initially in the login form for user name 230 // no default_user_name default value 231 \$default_user_name = ''; 232 233 // default text that is placed initially in the login form for password 234 // no default_password default value 235 \$default_password = ''; 236 237 // create user with default username and password 238 // create_default_user default value = false 239 \$create_default_user = false; 240 241 // default_user_is_admin default value = false 242 \$default_user_is_admin = false; 243 244 // if your MySQL/PHP configuration does not support persistent connections set this to true to avoid a large performance slowdown 245 // disable_persistent_connections default value = false 246 \$disable_persistent_connections = false; 247 248 //Master currency name 249 \$currency_name = '{$this->currencyName}'; 250 251 // default charset 252 // default charset default value = 'UTF-8' or 'ISO-8859-1' 253 \$default_charset = '{$this->vtCharset}'; 254 255 // default language 256 // default_language default value = en_us 257 \$default_language = 'en_us'; 258 259 // add the language pack name to every translation string in the display. 260 // translation_string_prefix default value = false 261 \$translation_string_prefix = false; 262 263 //Option to cache tabs permissions for speed. 264 \$cache_tab_perms = true; 265 266 //Option to hide empty home blocks if no entries. 267 \$display_empty_home_blocks = false; 268 269 //Disable Stat Tracking of vtiger CRM instance 270 \$disable_stats_tracking = false; 271 272 // Generating Unique Application Key 273 \$application_unique_key = '".md5(time() + rand(1,9999999) + md5($this->rootDirectory)) ."'; 274 275 // trim descriptions, titles in listviews to this value 276 \$listview_max_textlength = 40; 277 278 // Maximum time limit for PHP script execution (in seconds) 279 \$php_max_execution_time = 0; 280 281 // Set the default timezone as per your preference 282 //\$default_timezone = ''; 283 284 /** If timezone is configured, try to set it */ 285 if(isset(\$default_timezone) && function_exists('date_default_timezone_set')) { 286 @date_default_timezone_set(\$default_timezone); 287 }"; 288 return $configFileContents; 289 } 290 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |