/** * Writes the specified binary or text data to a file * @param string The file path * @param mixed The data to be written * @param string The attributes for the write operation ('w' or 'wb') */ function putDataToFile($fileName, &$data, $writeAttributes) { $fileHandle = @sugar_fopen($fileName, $writeAttributes); if ($fileHandle) { fwrite($fileHandle, $data); fclose($fileHandle); } }
function write_logic_file($module_name, $contents) { $file = "modules/" . $module_name . '/logic_hooks.php'; $file = create_custom_directory($file); $fp = sugar_fopen($file, 'wb'); fwrite($fp, $contents); fclose($fp); //end function write_logic_file }
function pre_uninstall() { require_once 'include/utils/array_utils.php'; require_once 'include/utils/file_utils.php'; require_once 'include/utils/sugar_file_utils.php'; $modules_array = array('Accounts', 'Contacts', 'Leads'); foreach ($modules_array as $module) { $file = "custom/modules/{$module}/metadata/detailviewdefs.php"; if (file_exists($file)) { include $file; if (isset($viewdefs[$module]['DetailView']['templateMeta']['form']['buttons']['AOS_GENLET'])) { unset($viewdefs[$module]['DetailView']['templateMeta']['form']['buttons']['AOS_GENLET']); $new_contents = file_get_contents($file); $old_contents_v1 = "\$viewdefs['{$module}']['DetailView']['templateMeta']['form']['buttons']['AOS_GENLET'] = array('customCode'=>'<input type=\"button\" class=\"button\" onClick=\"showPopup();\" value=\"{\$APP.LBL_GENERATE_LETTER}\">');"; $old_contents_v2 = "customCode' => '<input type=\"button\" class=\"button\" onClick=\"showPopup();\" value=\"{\$APP.LBL_GENERATE_LETTER}\">"; $new_contents = str_replace($old_contents_v1, "", $new_contents); $new_contents = str_replace($old_contents_v2, "", $new_contents); $new_contents = str_replace("AOS_GENLET", "", $new_contents); $fp = sugar_fopen($file, 'wb'); fwrite($fp, $new_contents); fclose($fp); } } } /** remove following: $entry_point_registry['formLetter'] = array('file' => 'modules/AOS_PDF_Templates/formLetterPdf.php', 'auth' => true); $entry_point_registry['generatePdf'] = array('file' => 'modules/AOS_PDF_Templates/generatePdf.php', 'auth' => true); */ $remove_entry_point = false; $new_contents = ""; $entry_point_registry = null; if (file_exists("custom/include/MVC/Controller/entry_point_registry.php")) { include "custom/include/MVC/Controller/entry_point_registry.php"; if (isset($entry_point_registry['formLetter'])) { $remove_entry_point = true; unset($entry_point_registry['formLetter']); } if (isset($entry_point_registry['generatePdf'])) { $remove_entry_point = true; unset($entry_point_registry['generatePdf']); } if ($remove_entry_point == true) { foreach ($entry_point_registry as $entryPoint => $epArray) { $new_contents .= "\$entry_point_registry['" . $entryPoint . "'] = array('file' => '" . $epArray['file'] . "' , 'auth' => '" . $epArray['auth'] . "'); \n"; } $new_contents = "<?php\n{$new_contents}\n?>"; $file = 'custom/include/MVC/Controller/entry_point_registry.php'; $fp = sugar_fopen($file, 'wb'); fwrite($fp, $new_contents); fclose($fp); } } }
function save_xml_file($filename, $xml_file) { global $app_strings; if (!($handle = sugar_fopen($filename, 'w'))) { $GLOBALS['log']->debug("Cannot open file ({$filename})"); return; } if (fwrite($handle, $xml_file) === FALSE) { $GLOBALS['log']->debug("Cannot write to file ({$filename})"); return false; } $GLOBALS['log']->debug("Success, wrote ({$xml_file}) to file ({$filename})"); fclose($handle); return true; }
function createAppStringsCache($lang = 'en_us') { // cn: bug 8242 - non-US langpack chokes $app_strings = return_application_language($lang); $app_list_strings = return_app_list_strings_language($lang); $json = getJSONobj(); $app_list_strings_encoded = $json->encode($app_list_strings); $app_strings_encoded = $json->encode($app_strings); $str = <<<EOQ SUGAR.language.setLanguage('app_strings', {$app_strings_encoded}); SUGAR.language.setLanguage('app_list_strings', {$app_list_strings_encoded}); EOQ; $cacheDir = create_cache_directory('jsLanguage/'); if ($fh = @sugar_fopen($cacheDir . $lang . '.js', "w")) { fputs($fh, $str); fclose($fh); } }
/** * Using curl we will download the file from the depot server * * @param session_id the session_id this file is queued for * @param file_name the file_name to download * @param save_dir (optional) if specified it will direct where to save the file once downloaded * @param download_sever (optional) if specified it will direct the url for the download * * @return the full path of the saved file */ function download($session_id, $file_name, $save_dir = '', $download_server = '') { if (empty($save_dir)) { $save_dir = PACKAGE_MANAGER_DOWNLOAD_PATH; } if (empty($download_server)) { $download_server = PACKAGE_MANAGER_DOWNLOAD_SERVER; } $download_server .= PACKAGE_MANAGER_DOWNLOAD_PAGE; $ch = curl_init($download_server . '?filename=' . $file_name); $fp = sugar_fopen($save_dir . $file_name, 'w'); curl_setopt($ch, CURLOPT_COOKIE, 'PHPSESSID=' . $session_id . ';'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_exec($ch); curl_close($ch); fclose($fp); return $save_dir . $file_name; }
/** * DetailView constructor * This is the DetailView constructor responsible for processing the new * Meta-Data framework * * @param $module String value of module this detail view is for * @param $focus An empty sugarbean object of module * @param $id The record id to retrieve and populate data for * @param $metadataFile String value of file location to use in overriding default metadata file * @param tpl String value of file location to use in overriding default Smarty template * */ function setup($module, $focus, $metadataFile = null, $tpl = 'include/DetailView/DetailView.tpl') { $this->th = new TemplateHandler(); $this->th->ss =& $this->ss; $this->focus = $focus; $this->tpl = $tpl; $this->module = $module; $this->metadataFile = $metadataFile; if (isset($GLOBALS['sugar_config']['disable_vcr'])) { $this->showVCRControl = !$GLOBALS['sugar_config']['disable_vcr']; } if (!empty($this->metadataFile) && file_exists($this->metadataFile)) { require_once $this->metadataFile; } else { //If file doesn't exist we create a best guess if (!file_exists("modules/{$this->module}/metadata/detailviewdefs.php") && file_exists("modules/{$this->module}/DetailView.html")) { global $dictionary; $htmlFile = "modules/" . $this->module . "/DetailView.html"; $parser = new DetailViewMetaParser(); if (!file_exists('modules/' . $this->module . '/metadata')) { sugar_mkdir('modules/' . $this->module . '/metadata'); } $fp = sugar_fopen('modules/' . $this->module . '/metadata/detailviewdefs.php', 'w'); fwrite($fp, $parser->parse($htmlFile, $dictionary[$focus->object_name]['fields'], $this->module)); fclose($fp); } //Flag an error... we couldn't create the best guess meta-data file if (!file_exists("modules/{$this->module}/metadata/detailviewdefs.php")) { global $app_strings; $error = str_replace("[file]", "modules/{$this->module}/metadata/detailviewdefs.php", $app_strings['ERR_CANNOT_CREATE_METADATA_FILE']); $GLOBALS['log']->fatal($error); echo $error; die; } require_once "modules/{$this->module}/metadata/detailviewdefs.php"; } $this->defs = $viewdefs[$this->module][$this->view]; }
/** * Constructor * * @param string $filename * @param string $delimiter * @param string $enclosure * @param bool $deleteFile * @param bool $checkUploadPath * @param int $rowsCount */ public function __construct($filename, $delimiter = ',', $enclosure = '', $deleteFile = true, $checkUploadPath = true, $rowsCount = 0) { if (!is_file($filename) || !is_readable($filename)) { return false; } if ($checkUploadPath && UploadStream::path($filename) == null) { $GLOBALS['log']->fatal("ImportFile detected attempt to access to the following file not within the sugar upload dir: {$filename}"); return null; } // turn on auto-detection of line endings to fix bug #10770 ini_set('auto_detect_line_endings', '1'); $this->_fp = sugar_fopen($filename, 'r'); $this->_sourcename = $filename; $this->_deleteFile = $deleteFile; $this->_delimiter = empty($delimiter) ? ',' : $delimiter; if ($this->_delimiter == '\\t') { $this->_delimiter = "\t"; } $this->_enclosure = empty($enclosure) ? '' : trim($enclosure); // Autodetect does setFpAfterBOM() $this->_encoding = $this->autoDetectCharacterSet(); $this->_rowsCount = $rowsCount; }
function pre_install() { //2.1 remove legacy layout and vardefs files from custom/Extension/modules that are 'forgotten' by uninstaller $file_list = array('Accounts', 'Contacts', 'Documents', 'Opportunities', 'Project'); $dir = 'custom/Extension/modules/'; foreach ($file_list as $file) { if (file_exists($dir . $file . '/Ext/Layoutdefs/' . $file . '.php')) { unlink($dir . $file . '/Ext/Layoutdefs/' . $file . '.php'); } if (file_exists($dir . $file . '/Ext/Vardefs/' . $file . '.php')) { unlink($dir . $file . '/Ext/Vardefs/' . $file . '.php'); } } // Now cleanup all files in custom/Extension/ that have filename start with oqc $custom_dir = 'custom/Extension'; //$GLOBALS['log']->error("Custom directory structure is ". var_export(glob($custom_dir.'/*'),true)); if (is_dir($custom_dir)) { oqc_cleanup($custom_dir); } // This is the hack to make oqc_CreatePopup available for non-admin users // Required for button Create Attachement to work in Quotes and Contracts //TODO Make oqc_Create_popup work without this hack $str = "<?php \n //WARNING: The contents of this file are auto-generated\n"; $str .= "\$modules_exempt_from_availability_check['oqc_CreatePopup'] = 'oqc_CreatePopup';\n"; $str .= "\$modInvisList[] = 'oqc_CreatePopup';\n"; $str .= "\n?>"; if (!file_exists("custom/Extension/application/Ext/Include")) { mkdir_recursive("custom/Extension/application/Ext/Include", true); } if (file_exists("custom/Extension/application/Ext/Include/oqc_CreatePopup.php")) { unlink("custom/Extension/application/Ext/Include/oqc_CreatePopup.php"); } $out = sugar_fopen("custom/Extension/application/Ext/Include/oqc_CreatePopup.php", 'w'); fwrite($out, $str); fclose($out); }
/** * testRangeSearchWithSavedReportValues * This test attempts to simulate testing what would happen should a saved report be invoked against * a range search field * */ public function testRangeSearchWithSavedReportValues() { require_once 'include/SugarFields/Fields/Datetime/SugarFieldDatetime.php'; $parentFieldArray = 'fields'; $vardef = array(); $vardef['name'] = 'date_closed_advanced'; $vardef['vname'] = 'LBL_DATE_CLOSED'; $opportunity = new Opportunity(); $vardef = $opportunity->field_defs['date_closed']; $vardef['name'] = 'date_closed_advanced'; $vardef['options'] = array('=' => 'Equals', 'not_equal' => 'Not On', 'greater_than' => ' After', 'less_than' => ' Before', 'last_7_days' => ' Last 7 Days', 'next_7_days' => ' Next 7 Days', 'last_30_days' => ' Last 30 Days', 'next_30_days' => ' Next 30 Days', 'last_month' => ' Last Month', 'this_month' => ' This Month', 'next_month' => ' Next Month', 'last_year' => ' Last Year', 'this_year' => ' This Year', 'next_year' => ' Next Year', 'between' => ' Is Between'); $displayParams = array('labelSpan' => '', 'fieldSpan' => ''); $tabindex = ''; $sugarFieldDatetime = new SugarFieldDatetime('Datetime'); $_REQUEST['action'] = 'SearchForm'; $html = $sugarFieldDatetime->getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex); //Write this widget's contents to a file $this->smartyTestFile = 'tests/include/SearchForm/RangeSearchTest.tpl'; $handle = sugar_fopen($this->smartyTestFile, 'wb'); fwrite($handle, $html); //Check that the template exists before we proceed with further tests $this->assertTrue(file_exists($this->smartyTestFile)); //Stuff Smarty variables $vardef['value'] = ''; $fields = array(); $fields['date_closed_advanced'] = $vardef; //Create Smarty instance require_once 'include/Sugar_Smarty.php'; $ss = new Sugar_Smarty(); //Assign Smarty variables $ss->assign('fields', $fields); $ss->assign('APP', $GLOBALS['app_strings']); $ss->assign('CALENDAR_FORMAT', 'm-d-Y'); //Simulate the request with saved report value $_REQUEST['date_closed_advanced'] = '07-03-2009'; $output = $ss->fetch($this->smartyTestFile); $this->assertRegExp('/range_date_closed_advanced\\"\\s+?value\\s*?\\=s*?\'07\\-03\\-2009\'/', $output); //Simulate the request with range search value $_REQUEST['range_date_closed_advanced'] = '07-04-2009'; $output = $ss->fetch($this->smartyTestFile); $this->assertRegExp('/range_date_closed_advanced\\"\\s+?value\\s*?\\=s*?\'07\\-04\\-2009\'/', $output); }
if ($ignore_self) { echo $mod_strings['LBL_IT_WILL_BE_IGNORED']; } if (empty($_SESSION['log_file_size'])) { $_SESSION['log_file_size'] = 0; } $cur_size = filesize($logFile); $_SESSION['last_log_file_size'] = $cur_size; $pos = 0; if ($cur_size >= $_SESSION['log_file_size']) { $pos = $_SESSION['log_file_size'] - $cur_size; } if ($_SESSION['log_file_size'] == $cur_size) { echo $mod_strings['LBL_LOG_NOT_CHANGED'] . '<br>'; } else { $fp = sugar_fopen($logFile, 'r'); fseek($fp, $pos, SEEK_END); echo '<pre>'; while ($line = fgets($fp)) { $line = filter_var($line, FILTER_SANITIZE_SPECIAL_CHARS); //preg_match('/[^\]]*\[([0-9]*)\] ([a-zA-Z]+) ([a-zA-Z0-9\.]+) - (.*)/', $line, $result); preg_match('/[^\\]]*\\[([0-9]*)\\]/', $line, $result); ob_flush(); flush(); if (empty($result) && $lastMatch) { echo $line; } else { $lastMatch = false; if (empty($result) || $ignore_self && $result[LOG_NAME] == $_SERVER['REMOTE_ADDR']) { } else { if (empty($filter) || !$reg_ex && substr_count($line, $filter) > 0 || $reg_ex && preg_match($filter, $line)) {
/** * loads the sql file into an array * @param array persistence * @param bool preflight Flag to load for Preflight or Commit * @return array persistence */ function preflightCheckJsonPrepSchemaCheck($persistence, $preflight = true) { global $mod_strings; global $db; global $sugar_db_version; global $manifest; unset($persistence['sql_to_run']); $persistence['sql_to_check'] = array(); $persistence['sql_to_check_backup'] = array(); if (isset($persistence['sql_check_done'])) { // reset flag to not check (on Recheck) unset($persistence['sql_check_done']); unset($persistence['sql_errors']); } // get schema script if not loaded if ($preflight) { logThis('starting schema preflight check...'); } else { logThis('Preparing SQL statements for sequential execution...'); } if (empty($sugar_db_version)) { include 'sugar_version.php'; } if (!isset($manifest['version']) || empty($manifest['version'])) { include $persistence['unzip_dir'] . '/manifest.php'; } $origVersion = implodeVersion($sugar_db_version); $destVersion = implodeVersion($manifest['version']); $script_name = $db->getScriptType(); $sqlScript = $persistence['unzip_dir'] . "/scripts/{$origVersion}_to_{$destVersion}_{$script_name}.sql"; $newTables = array(); logThis('looking for schema script at: ' . $sqlScript); if (is_file($sqlScript)) { logThis('found schema upgrade script: ' . $sqlScript); $fp = sugar_fopen($sqlScript, 'r'); if (!empty($fp)) { $completeLine = ''; while ($line = fgets($fp)) { if (strpos($line, '--') === false) { $completeLine .= " " . trim($line); if (strpos($line, ';') !== false) { $completeLine = str_replace(';', '', $completeLine); $persistence['sql_to_check'][] = $completeLine; $completeLine = ''; //reset for next loop } } } $persistence['sql_total'] = count($persistence['sql_to_check']); } else { logThis('*** ERROR: could not read schema script: ' . $sqlScript); $persistence['sql_errors'][] = $mod_strings['ERR_UW_FILE_NOT_READABLE'] . '::' . $sqlScript; } } // load a new array if for commit if ($preflight) { $persistence['sql_to_check_backup'] = $persistence['sql_to_check']; $persistence['sql_to_run'] = $persistence['sql_to_check']; echo "1% " . $mod_strings['LBL_UW_DONE']; } else { $persistence['sql_to_run'] = $persistence['sql_to_check']; unset($persistence['sql_to_check']); } return $persistence; }
function retrieveFile($id, $filename) { if (empty($filename)) { return ''; } $this->upload_file->stored_file_name = $filename; $filepath = $this->upload_file->get_upload_path($id); if (file_exists($filepath)) { $fp = sugar_fopen($filepath, 'rb'); $file = fread($fp, filesize($filepath)); fclose($fp); return base64_encode($file); } return -1; }
// re-minify the JS source files $_REQUEST['root_directory'] = getcwd(); $_REQUEST['js_rebuild_concat'] = 'rebuild'; require_once 'jssource/minify.php'; //Add the cache cleaning here. if (function_exists('deleteCache')) { logThis('Call deleteCache', $path); @deleteCache(); } // creating full text search logic hooks // this will be merged into application/Ext/LogicHooks/logichooks.ext.php // when rebuild_extensions is called logThis(' Writing FTS hooks'); if (!function_exists('createFTSLogicHook')) { $customFileLoc = create_custom_directory('Extension/application/Ext/LogicHooks/SugarFTSHooks.php'); $fp = sugar_fopen($customFileLoc, 'wb'); $contents = <<<CIA <?php if (!isset(\$hook_array) || !is_array(\$hook_array)) { \$hook_array = array(); } if (!isset(\$hook_array['after_save']) || !is_array(\$hook_array['after_save'])) { \$hook_array['after_save'] = array(); } \$hook_array['after_save'][] = array(1, 'fts', 'include/SugarSearchEngine/SugarSearchEngineQueueManager.php', 'SugarSearchEngineQueueManager', 'populateIndexQueue'); CIA; fwrite($fp, $contents); fclose($fp); } else { createFTSLogicHook('Extension/application/Ext/LogicHooks/SugarFTSHooks.php'); }
function createFTSLogicHook($filePath = 'application/Ext/LogicHooks/logichooks.ext.php') { $customFileLoc = create_custom_directory($filePath); $fp = sugar_fopen($customFileLoc, 'wb'); $contents = <<<CIA <?php if (!isset(\$hook_array) || !is_array(\$hook_array)) { \$hook_array = array(); } if (!isset(\$hook_array['after_save']) || !is_array(\$hook_array['after_save'])) { \$hook_array['after_save'] = array(); } \$hook_array['after_save'][] = array(1, 'fts', 'include/SugarSearchEngine/SugarSearchEngineQueueManager.php', 'SugarSearchEngineQueueManager', 'populateIndexQueue'); CIA; fwrite($fp, $contents); fclose($fp); }
function save($key_name, $duplicate = false, $rename = false) { $header = file_get_contents('modules/ModuleBuilder/MB/header.php'); $save_path = $this->path . '/language'; mkdir_recursive($save_path); foreach ($this->strings as $lang => $values) { //Check if the module Label has changed. $renameLang = $rename || empty($values) || isset($values['LBL_MODULE_NAME']) && $this->label != $values['LBL_MODULE_NAME']; $mod_strings = return_module_language(str_replace('.lang.php', '', $lang), 'ModuleBuilder'); $required = array('LBL_LIST_FORM_TITLE' => $this->label . " " . $mod_strings['LBL_LIST'], 'LBL_MODULE_NAME' => $this->label, 'LBL_MODULE_TITLE' => $this->label, 'LBL_HOMEPAGE_TITLE' => $mod_strings['LBL_HOMEPAGE_PREFIX'] . " " . $this->label, 'LNK_NEW_RECORD' => $mod_strings['LBL_CREATE'] . " " . $this->label, 'LNK_LIST' => $mod_strings['LBL_VIEW'] . " " . $this->label, 'LNK_IMPORT_' . strtoupper($this->key_name) => translate('LBL_IMPORT') . " " . $this->label, 'LBL_SEARCH_FORM_TITLE' => $mod_strings['LBL_SEARCH'] . " " . $this->label, 'LBL_HISTORY_SUBPANEL_TITLE' => $mod_strings['LBL_HISTORY'], 'LBL_ACTIVITIES_SUBPANEL_TITLE' => $mod_strings['LBL_ACTIVITIES'], 'LBL_' . strtoupper($this->key_name) . '_SUBPANEL_TITLE' => $this->label, 'LBL_NEW_FORM_TITLE' => $mod_strings['LBL_NEW'] . " " . $this->label); foreach ($required as $k => $v) { if (empty($values[$k]) || $renameLang) { $values[$k] = $v; } } write_array_to_file('mod_strings', $values, $save_path . '/' . $lang, 'w', $header); } $app_save_path = $this->path . '/../../language/application'; mkdir_recursive($app_save_path); $key_changed = $this->key_name != $key_name; foreach ($this->appListStrings as $lang => $values) { // Load previously created modules data // $app_list_strings = array (); --- fix for issue #305 $neededFile = $app_save_path . '/' . $lang; if (file_exists($neededFile)) { include $neededFile; } if (!$duplicate) { unset($values['moduleList'][$this->key_name]); } // $values = sugarLangArrayMerge($values, $app_list_strings); --- fix for issue #305 $values['moduleList'][$key_name] = $this->label; $appFile = $header . "\n"; require_once 'include/utils/array_utils.php'; $this->getGlobalAppListStringsForMB($values); foreach ($values as $key => $array) { if ($duplicate) { //keep the original when duplicating $appFile .= override_value_to_string_recursive2('app_list_strings', $key, $array); } $okey = $key; if ($key_changed) { $key = str_replace($this->key_name, $key_name, $key); } if ($key_changed) { $key = str_replace(strtolower($this->key_name), strtolower($key_name), $key); } // if we aren't duplicating or the key has changed let's add it if (!$duplicate || $okey != $key) { $appFile .= override_value_to_string_recursive2('app_list_strings', $key, $array); } } $fp = sugar_fopen($app_save_path . '/' . $lang, 'w'); fwrite($fp, $appFile); fclose($fp); } }
/** * Performs the actual file write. Abstracted from writeCacheFile() for * flexibility * @param array $array The array to write to the cache * @param string $file Full path (relative) with cache file name * @return bool */ function _writeCacheFile($array, $file) { global $sugar_config; $arrayString = var_export_helper($array); $date = date("r"); $the_string = <<<eoq <?php // created: {$date} \t\$cacheFile = {$arrayString}; ?> eoq; if ($fh = @sugar_fopen($file, "w")) { fputs($fh, $the_string); fclose($fh); return true; } else { $GLOBALS['log']->debug("EMAILUI: Could not write cache file [ {$file} ]"); return false; } }
function saveSubPanelDefOverride($panel, $subsection, $override) { global $layout_defs, $beanList; //save the new subpanel $name = "subpanel_layout['list_fields']"; //bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels $path = 'custom/modules/' . $panel->_instance_properties['module'] . '/metadata/subpanels'; //bug# 40171: "Custom subpanels not working as expected" //each custom subpanel needs to have a unique custom def file $filename = $panel->parent_bean->object_name . "_subpanel_" . $panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it) $oldName1 = '_override' . $panel->parent_bean->object_name . $panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name']; $oldName2 = '_override' . $panel->parent_bean->object_name . $panel->_instance_properties['get_subpanel_data']; if (file_exists('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$oldName1}.php")) { unlink('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$oldName1}.php"); } if (file_exists('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$oldName2}.php")) { unlink('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$oldName2}.php"); } $extname = '_override' . $filename; //end of bug# 40171 mkdir_recursive($path, true); write_array_to_file($name, $override, $path . '/' . $filename . '.php'); //save the override for the layoutdef //tyoung 10.12.07 pushed panel->name to lowercase to match case in subpaneldefs.php files - //gave error on bad index 'module' as this override key didn't match the key in the subpaneldefs $name = "layout_defs['" . $panel->parent_bean->module_dir . "']['subpanel_setup']['" . strtolower($panel->name) . "']"; // $GLOBALS['log']->debug('SubPanel.php->saveSubPanelDefOverride(): '.$name); $newValue = override_value_to_string($name, 'override_subpanel_name', $filename); mkdir_recursive('custom/Extension/modules/' . $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true); $fp = sugar_fopen('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$extname}.php", 'w'); fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n{$newValue}\n?>"); fclose($fp); require_once 'ModuleInstall/ModuleInstaller.php'; $moduleInstaller = new ModuleInstaller(); $moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs $moduleInstaller->rebuild_layoutdefs(); if (file_exists('modules/' . $panel->parent_bean->module_dir . '/layout_defs.php')) { include 'modules/' . $panel->parent_bean->module_dir . '/layout_defs.php'; } if (file_exists('custom/modules/' . $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) { include 'custom/modules/' . $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'; } }
function setLastUser($user_id, $id) { $_SESSION['lastuser'][$id] = $user_id; $file = create_cache_directory('modules/AOW_WorkFlow/Users/') . $id . 'lastUser.cache.php'; $arrayString = var_export_helper(array('User' => $user_id)); $content = <<<eoq <?php \t\$lastUser = {$arrayString}; ?> eoq; if ($fh = @sugar_fopen($file, 'w')) { fputs($fh, $content); fclose($fh); } return true; }
function getLicenseContents($filename) { $license_file = ''; if (file_exists($filename) && filesize($filename) > 0) { $fh = sugar_fopen($filename, 'r') or die("License file not found!"); $license_file = fread($fh, filesize($filename)); fclose($fh); } return $license_file; }
function installLog($entry) { global $mod_strings; $nl = ' ' . gmdate("Y-m-d H:i:s") . '...'; $log = clean_path(getcwd() . '/install.log'); // create if not exists if (!file_exists($log)) { $fp = @sugar_fopen($log, 'w+'); // attempts to create file if (!is_resource($fp)) { $GLOBALS['log']->fatal('could not create the install.log file'); } } else { $fp = @sugar_fopen($log, 'a+'); // write pointer at end of file if (!is_resource($fp)) { $GLOBALS['log']->fatal('could not open/lock install.log file'); } } if (@fwrite($fp, $nl . $entry) === false) { $GLOBALS['log']->fatal('could not write to install.log: ' . $entry); } if (is_resource($fp)) { fclose($fp); } }
function merge_files($path, $name, $filter = '', $application = false) { if (!$application) { $GLOBALS['log']->debug(get_class($this) . "->merge_files() : merging module files in custom/Extension/modules/<module>/{$path} to custom/modules/<module>/{$path}{$name}"); foreach ($this->modules as $module) { //$GLOBALS['log']->debug("Merging Files for: ".$module); //$GLOBALS['log']->debug("Merging Files for path: ".$path); $extension = "<?php \n //WARNING: The contents of this file are auto-generated\n"; $extpath = "modules/{$module}/{$path}"; $module_install = 'custom/Extension/' . $extpath; $shouldSave = false; if (is_dir($module_install)) { $dir = dir($module_install); $shouldSave = true; $override = array(); while ($entry = $dir->read()) { if ((empty($filter) || substr_count($entry, $filter) > 0) && is_file($module_install . '/' . $entry) && $entry != '.' && $entry != '..' && strtolower(substr($entry, -4)) == ".php") { if (substr($entry, 0, 9) == '_override') { $override[] = $entry; } else { $file = file_get_contents($module_install . '/' . $entry); $GLOBALS['log']->debug(get_class($this) . "->merge_files(): found {$module_install}{$entry}"); $extension .= "\n" . str_replace(array('<?php', '?>', '<?PHP', '<?'), array('', '', '', ''), $file); } } } foreach ($override as $entry) { $file = file_get_contents($module_install . '/' . $entry); $extension .= "\n" . str_replace(array('<?php', '?>', '<?PHP', '<?'), array('', '', '', ''), $file); } } $extension .= "\n?>"; if ($shouldSave) { if (!file_exists("custom/{$extpath}")) { mkdir_recursive("custom/{$extpath}", true); } $out = sugar_fopen("custom/{$extpath}/{$name}", 'w'); fwrite($out, $extension); fclose($out); } else { if (file_exists("custom/{$extpath}/{$name}")) { unlink("custom/{$extpath}/{$name}"); } } } } $GLOBALS['log']->debug("Merging application files for {$name} in {$path}"); //Now the application stuff $extension = "<?php \n //WARNING: The contents of this file are auto-generated\n"; $extpath = "application/{$path}"; $module_install = 'custom/Extension/' . $extpath; $shouldSave = false; if (is_dir($module_install)) { $dir = dir($module_install); while ($entry = $dir->read()) { $shouldSave = true; if ((empty($filter) || substr_count($entry, $filter) > 0) && is_file($module_install . '/' . $entry) && $entry != '.' && $entry != '..' && strtolower(substr($entry, -4)) == ".php") { $file = file_get_contents($module_install . '/' . $entry); $extension .= "\n" . str_replace(array('<?php', '?>', '<?PHP', '<?'), array('', '', '', ''), $file); } } } $extension .= "\n?>"; if ($shouldSave) { if (!file_exists("custom/{$extpath}")) { mkdir_recursive("custom/{$extpath}", true); } $out = sugar_fopen("custom/{$extpath}/{$name}", 'w'); fwrite($out, $extension); fclose($out); } else { if (file_exists("custom/{$extpath}/{$name}")) { unlink("custom/{$extpath}/{$name}"); } } }
/** * function to save XML contents into a file * * @param string $xmlFilename location of the xml file * string $xmlContents contents of the xml file * @return string boolean denoting whether save has failed */ function saveXMLFile($xmlFilename, $xmlContents) { global $app_strings; global $locale; $xmlContents = chr(255) . chr(254) . $GLOBALS['locale']->translateCharset($xmlContents, 'UTF-8', 'UTF-16LE'); // Create dir if it doesn't exist $dir = dirname($xmlFilename); if (!sugar_is_dir($dir)) { sugar_mkdir($dir, null, true); } // open file if (!($fh = sugar_fopen($xmlFilename, 'w'))) { $GLOBALS['log']->debug("Cannot open file ({$xmlFilename})"); return; } // write the contents to the file if (fwrite($fh, $xmlContents) === FALSE) { $GLOBALS['log']->debug("Cannot write to file ({$xmlFilename})"); return false; } $GLOBALS['log']->debug("Success, wrote ({$xmlContents}) to file ({$xmlFilename})"); fclose($fh); return true; }
/** * fix_dropdown_list * This method attempts to fix dropdown lists that were incorrectly named. * There were versions of SugarCRM that did not enforce naming convention rules * for the dropdown list field name. This method attempts to resolve that by * fixing the language files that may have been affected and then updating the * fields_meta_data table accordingly. It also refreshes any vardefs that may * have been affected. * */ function fix_dropdown_list() { if (file_exists('custom/include/language')) { $files = array(); $affected_modules = array(); $affected_keys = array(); getFiles($files, 'custom/include/language', '/\\.php$/i'); foreach ($files as $file) { if (file_exists($file . '.bak')) { $bak_mod_time = filemtime($file . '.bak'); $php_mod_time = filemtime($file); //We're saying if the .php file was modified 30 seconds no more than php.bak file then we //run these additional cleanup checks if ($php_mod_time - $bak_mod_time < 30) { $app_list_strings = array(); $GLOBALS['app_list_strings'] = array(); require $file . '.bak'; $bak_app_list_strings = array_merge($app_list_strings, $GLOBALS['app_list_strings']); $app_list_strings = array(); $GLOBALS['app_list_strings'] = array(); require $file; $php_app_list_strings = array_merge($app_list_strings, $GLOBALS['app_list_strings']); //Get the file contents $contents = file_get_contents($file); //Now simulate a fix for the file before we compare w/ the .php file //we also append to the $contents foreach ($bak_app_list_strings as $key => $entry) { if (preg_match('/([^A-Za-z_])/', $key, $matches) && is_array($entry)) { $new_key = preg_replace('/[^A-Za-z_]/', '_', $key); $bak_app_list_strings[$new_key] = $bak_app_list_strings[$key]; unset($bak_app_list_strings[$key]); //Now if the entry doesn't exists in the .php file, then add to contents if (!isset($php_app_list_strings[$new_key])) { $contents .= "\n\$GLOBALS['app_list_strings']['{$new_key}'] = " . var_export_helper($bak_app_list_strings[$new_key]) . ";"; } } //if } //foreach //Now load the .php file to do the comparison foreach ($php_app_list_strings as $key => $entry) { if (isset($bak_app_list_strings[$key])) { $diff = array_diff($bak_app_list_strings[$key], $entry); if (!empty($diff)) { //There is a difference, so copy the $bak_app_list_strings version into the .php file $contents .= "\n\$GLOBALS['app_list_strings']['{$key}'] = " . var_export_helper($bak_app_list_strings[$key]) . ";"; } //if } //if } //foreach //Now write out the file contents //Create backup just in case copy($file, $file . '.php_bak'); $fp = @sugar_fopen($file, 'w'); if ($fp) { fwrite($fp, $contents); fclose($fp); } else { $GLOBALS['log']->error("Unable to update file contents in fix_dropdown_list for {$file}"); } //if-else } } unset($GLOBALS['app_strings']); unset($GLOBALS['app_list_strings']); $app_list_strings = array(); require $file; $touched = false; $contents = file_get_contents($file); if (!isset($GLOBALS['app_list_strings'])) { $GLOBALS['app_list_strings'] = $app_list_strings; } else { $GLOBALS['app_list_strings'] = array_merge($app_list_strings, $GLOBALS['app_list_strings']); } if (isset($GLOBALS['app_list_strings']) && is_array($GLOBALS['app_list_strings'])) { foreach ($GLOBALS['app_list_strings'] as $key => $entry) { if (preg_match('/([^A-Za-z_])/', $key, $matches) && is_array($entry)) { $result = $GLOBALS['db']->query("SELECT custom_module FROM fields_meta_data WHERE ext1 = '{$key}'"); if (!empty($result)) { while ($row = $GLOBALS['db']->fetchByAssoc($result)) { $custom_module = $row['custom_module']; if (!empty($GLOBALS['beanList'][$custom_module])) { $affected_modules[$custom_module] = $GLOBALS['beanList'][$custom_module]; } } //while } //Replace all invalid characters with '_' character $new_key = preg_replace('/[^A-Za-z_]/', '_', $key); $affected_keys[$key] = $new_key; $GLOBALS['app_list_strings'][$new_key] = $GLOBALS['app_list_strings'][$key]; unset($GLOBALS['app_list_strings'][$key]); $pattern_match = "/(\\[\\s*\\'{$key}\\'\\s*\\])/"; $new_key = "['{$new_key}']"; $out = preg_replace($pattern_match, $new_key, $contents); $contents = $out; $touched = true; } //if } //foreach //This is a check for g => h instances where the file contents were incorrectly written //and also fixes the scenario where via a UI upgrade, the app_list_strings were incorrectly //merged with app_list_strings variables declared elsewhere if (!$touched) { if (preg_match('/\\$GLOBALS\\s*\\[\\s*[\\"|\']app_list_strings[\\"|\']\\s*\\]\\s*=\\s*array\\s*\\(/', $contents)) { //Now also remove all the non-custom labels that were added if (preg_match('/language\\/([^\\.]+)\\.lang\\.php$/', $file, $matches)) { $language = $matches[1]; $app_list_strings = array(); if (file_exists("include/language/{$language}.lang.php")) { include "include/language/{$language}.lang.php"; } if (file_exists("include/language/{$language}.lang.override.php")) { $app_list_strings = _mergeCustomAppListStrings("include/language/{$language}.lang.override.php", $app_list_strings); } if (file_exists("custom/application/Ext/Language/{$language}.ext.lang.php")) { $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/{$language}.ext.lang.php", $app_list_strings); } if (file_exists("custom/application/Ext/Language/{$language}.lang.ext.php")) { $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/{$language}.lang.ext.php", $app_list_strings); } $all_non_custom_include_language_strings = $app_strings; $all_non_custom_include_language_list_strings = $app_list_strings; $unset_keys = array(); if (!empty($GLOBALS['app_list_strings'])) { foreach ($GLOBALS['app_list_strings'] as $key => $value) { $diff = array(); if (isset($all_non_custom_include_language_list_strings[$key])) { $diff = array_diff($all_non_custom_include_language_list_strings[$key], $GLOBALS['app_list_strings'][$key]); } if (!empty($all_non_custom_include_language_list_strings[$key]) && empty($diff)) { $unset_keys[] = $key; } } } foreach ($unset_keys as $key) { unset($GLOBALS['app_list_strings'][$key]); } if (!empty($GLOBALS['app_strings'])) { foreach ($GLOBALS['app_strings'] as $key => $value) { if (!empty($all_non_custom_include_language_strings[$key])) { unset($GLOBALS['app_strings'][$key]); } } } } //if(preg_match...) $out = "<?php \n"; if (!empty($GLOBALS['app_strings'])) { foreach ($GLOBALS['app_strings'] as $key => $entry) { $out .= "\n\$GLOBALS['app_strings']['{$key}']=" . var_export_helper($entry) . ";"; } } foreach ($GLOBALS['app_list_strings'] as $key => $entry) { $out .= "\n\$GLOBALS['app_list_strings']['{$key}']=" . var_export_helper($entry) . ";"; } //foreach $touched = true; } //if(preg_match...) } //if(!$touched) if ($touched) { //Create a backup just in case copy($file, $file . '.bak'); $fp = @sugar_fopen($file, 'w'); if ($fp) { fwrite($fp, $out); fclose($fp); } else { //If we can't update the file, just return $GLOBALS['log']->error("Unable to update file contents in fix_dropdown_list."); return; } } //if($touched) } //if } //foreach($files) //Update db entries (the order matters here... need to process database changes first) if (!empty($affected_keys)) { foreach ($affected_keys as $old_key => $new_key) { $GLOBALS['db']->query("UPDATE fields_meta_data SET ext1 = '{$new_key}' WHERE ext1 = '{$old_key}'"); } } //Update vardef files for affected modules if (!empty($affected_modules)) { foreach ($affected_modules as $module => $object) { VardefManager::refreshVardefs($module, $object); } } } }
/** * repairTableDictionaryExtFile * * There were some scenarios in 6.0.x whereby the files loaded in the extension tabledictionary.ext.php file * did not exist. This would cause warnings to appear during the upgrade. As a result, this * function scans the contents of tabledictionary.ext.php and then remove entries where the file does exist. */ function repairTableDictionaryExtFile() { $tableDictionaryExtDirs = array('custom/Extension/application/Ext/TableDictionary', 'custom/application/Ext/TableDictionary'); foreach ($tableDictionaryExtDirs as $tableDictionaryExt) { if (is_dir($tableDictionaryExt) && is_writable($tableDictionaryExt)) { $dir = dir($tableDictionaryExt); while (($entry = $dir->read()) !== false) { $entry = $tableDictionaryExt . '/' . $entry; if (is_file($entry) && preg_match('/\\.php$/i', $entry) && is_writeable($entry)) { if (function_exists('sugar_fopen')) { $fp = @sugar_fopen($entry, 'r'); } else { $fp = fopen($entry, 'r'); } if ($fp) { $altered = false; $contents = ''; while ($line = fgets($fp)) { if (preg_match('/\\s*include\\s*\\(\\s*[\'|\\"](.*?)[\\"|\']\\s*\\)\\s*;/', $line, $match)) { if (!file_exists($match[1])) { $altered = true; } else { $contents .= $line; } } else { $contents .= $line; } } fclose($fp); } if ($altered) { if (function_exists('sugar_fopen')) { $fp = @sugar_fopen($entry, 'w'); } else { $fp = fopen($entry, 'w'); } if ($fp && fwrite($fp, $contents)) { fclose($fp); } } } //if } //while } //if } }
* SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'include/formbase.php'; global $mod_strings; global $app_strings; if (!empty($_REQUEST['body_html'])) { $dir_path = "{$GLOBALS['sugar_config']['cache_dir']}generated_forms/"; if (!file_exists($dir_path)) { sugar_mkdir($dir_path, 0777); } $file = $dir_path . 'WebToLeadForm_' . time() . '.html'; $fp = sugar_fopen($file, 'wb'); fwrite($fp, from_html($_REQUEST['body_html'])); fclose($fp); } $xtpl = new XTemplate('modules/Campaigns/WebToLeadDownloadForm.html'); $xtpl->assign("MOD", $mod_strings); $xtpl->assign("APP", $app_strings); $webformlink = "<b>{$mod_strings['LBL_DOWNLOAD_TEXT_WEB_TO_LEAD_FORM']}</b></br>"; $webformlink .= "<a href={$GLOBALS['sugar_config']['cache_dir']}generated_forms/WebToLeadForm_" . time() . ".html>{$mod_strings['LBL_DOWNLOAD_WEB_TO_LEAD_FORM']}</a>"; $xtpl->assign("LINK_TO_WEB_FORM", $webformlink); $xtpl->parse("main"); $xtpl->out("main");
/** * equivalent for windows filesystem for PHP's is_writable() * @param string file Full path to the file/dir * @return bool true if writable */ function is_writable_windows($file) { if ($file[strlen($file) - 1] == '/') { return is_writable_windows($file . uniqid(mt_rand()) . '.tmp'); } // the assumption here is that Windows has an inherited permissions scheme // any file that is a descendant of an unwritable directory will inherit // that property and will trigger a failure below. if (is_dir($file)) { return true; } $file = str_replace("/", '\\', $file); if (file_exists($file)) { if (!($f = @sugar_fopen($file, 'r+'))) { return false; } fclose($f); return true; } if (!($f = @sugar_fopen($file, 'w'))) { return false; } fclose($f); unlink($file); return true; }
function saveJsonFile($jsonContents) { $this->jsonFilename = str_replace(".xml", ".js", $this->xmlFile); //$jsonContents = $GLOBALS['locale']->translateCharset($jsonContents, 'UTF-8', 'UTF-16LE'); // open file if (!($fh = sugar_fopen($this->jsonFilename, 'w'))) { $GLOBALS['log']->debug("Cannot open file ({$this->jsonFilename})"); return; } // write the contents to the file if (fwrite($fh, $jsonContents) === FALSE) { $GLOBALS['log']->debug("Cannot write to file ({$this->jsonFilename})"); return false; } $GLOBALS['log']->debug("Success, wrote ({$jsonContents}) to file ({$this->jsonFilename})"); fclose($fh); return true; }
* Description: ********************************************************************************/ $default_versions = array(); $new_db = DBManagerFactory::getInstance(); $db_version = '2.5.1'; $dirName = 'custom/include/language'; if (is_dir($dirName)) { $d = dir($dirName); while ($entry = $d->read()) { if ($entry != "." && $entry != "..") { // echo $dirName."/".$entry; if (is_file($dirName . "/" . $entry) && substr($entry, -9) == '.lang.php') { $custom_lang_file = $dirName . "/" . $entry; if (is_readable($custom_lang_file)) { $pattern = '/\\$app_list_strings[\\ ]*=[\\ ]*array/'; $handle = @sugar_fopen($custom_lang_file, 'rt'); $subject = fread($handle, filesize($custom_lang_file)); fclose($handle); $matches = preg_match($pattern, $subject); if ($matches > 0) { $db_version = '0'; } } } } } } //$default_versions[] = array('name'=>'Custom Labels', 'db_version' =>'3.0', 'file_version'=>'3.0'); $default_versions[] = array('name' => 'Chart Data Cache', 'db_version' => '3.5.1', 'file_version' => '3.5.1'); $default_versions[] = array('name' => 'htaccess', 'db_version' => '3.5.1', 'file_version' => '3.5.1'); //$default_versions[] = array('name'=>'DST Fix', 'db_version' =>'3.5.1b', 'file_version'=>'3.5.1b');
function executevardefs() { //BEGIN DUMP OF SUGAR SCHEMA (VARDEFS) //END DUMP OF SUGAR SCHEMA (VARDEFS) //BEGIN UPDATING PROGRESS BAR //This gets the vardefs, writes to a buffer, then I write to vardefschema.html global $cacheDir; global $beanList; global $beanFiles; global $dictionary; global $sugar_version; global $sugar_db_version; global $sugar_flavor; ob_start(); foreach ($beanList as $beanz) { // echo "Module: ".$beanz."<br>"; $path_parts = pathinfo($beanFiles[$beanz]); $vardefFileName = $path_parts['dirname'] . "/vardefs.php"; if (file_exists($vardefFileName)) { // echo "<br>".$vardefFileName."<br>"; include_once $vardefFileName; } } echo "<html>"; echo "<BODY>"; echo "<H1>Schema listing based on vardefs</H1>"; echo "<P>Sugar version: " . $sugar_version . " / Sugar DB version: " . $sugar_db_version . " / Sugar flavor: " . $sugar_flavor; echo "</P>"; echo "<style> th { text-align: left; } </style>"; $tables = array(); foreach ($dictionary as $vardef) { $tables[] = $vardef['table']; $fields[$vardef['table']] = $vardef['fields']; $comments[$vardef['table']] = $vardef['comment']; } asort($tables); foreach ($tables as $t) { $name = $t; if ($name == "does_not_exist") { continue; } $comment = $comments[$t]; echo "<h2>Table: {$t}</h2>\n\t\t<p><i>{$comment}</i></p>"; echo "<table border=\"0\" cellpadding=\"3\" class=\"tabDetailView\">"; echo '<TR BGCOLOR="#DFDFDF"> <TD NOWRAP ALIGN=left class=\\"tabDetailViewDL\\">Column</TD> <TD NOWRAP class=\\"tabDetailViewDL\\">Type</TD> <TD NOWRAP class=\\"tabDetailViewDL\\">Length</TD> <TD NOWRAP class=\\"tabDetailViewDL\\">Required</TD> <TD NOWRAP class=\\"tabDetailViewDL\\">Comment</TD> </TR>'; ksort($fields[$t]); foreach ($fields[$t] as $k => $v) { // we only care about physical tables ('source' can be 'non-db' or 'nondb' or 'function' ) if (isset($v['source'])) { continue; } $columnname = $v['name']; $columntype = $v['type']; $columndbtype = $v['dbType']; $columnlen = $v['len']; $columncomment = $v['comment']; $columnrequired = $v['required']; if (empty($columnlen)) { $columnlen = '<i>n/a</i>'; } if (empty($columncomment)) { $columncomment = '<i>(none)</i>'; } if (!empty($columndbtype)) { $columntype = $columndbtype; } if (empty($columnrequired) || $columnrequired == false) { $columndisplayrequired = 'no'; } else { $columndisplayrequired = 'yes'; } echo '<TR BGCOLOR="#FFFFFF" ALIGN=left> <TD ALIGN=left class=\\"tabDetailViewDF\\">' . $columnname . '</TD> <TD NOWRAP class=\\"tabDetailViewDF\\">' . $columntype . '</TD> <TD NOWRAP class=\\"tabDetailViewDF\\">' . $columnlen . '</TD> <TD NOWRAP class=\\"tabDetailViewDF"\\">' . $columndisplayrequired . '</TD> <TD WRAP class=\\"tabDetailViewDF\\">' . $columncomment . '</TD></TR>'; } echo "</table></p>"; } echo "</body></html>"; $vardefFormattedOutput = ob_get_contents(); ob_clean(); $handle = sugar_fopen($cacheDir . "vardefschema.html", "w"); if (fwrite($handle, $vardefFormattedOutput) === FALSE) { echo "Cannot write to file " . $cacheDir . "vardefschema.html<br>"; } fclose($handle); sodUpdateProgressBar(VARDEFS_WEIGHT); //END UPDATING PROGRESS BAR }