本文整理汇总了PHP中sugar_fopen函数的典型用法代码示例。如果您正苦于以下问题:PHP sugar_fopen函数的具体用法?PHP sugar_fopen怎么用?PHP sugar_fopen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sugar_fopen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: putDataToFile
/**
* 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);
}
}
示例2: write_logic_file
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
}
示例3: pre_uninstall
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);
}
}
}
示例4: save_xml_file
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;
}
示例5: createAppStringsCache
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);
}
}
示例6: download
/**
* 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;
}
示例7: setup
/**
* 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];
}
示例8: __construct
/**
* 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;
}
示例9: pre_install
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);
}
示例10: testRangeSearchWithSavedReportValues
/**
* 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);
}
示例11: filesize
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)) {
示例12: preflightCheckJsonPrepSchemaCheck
/**
* 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;
}
示例13: retrieveFile
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;
}
示例14: getcwd
// 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');
}
示例15: createFTSLogicHook
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);
}