当前位置: 首页>>代码示例>>PHP>>正文


PHP sugar_file_get_contents函数代码示例

本文整理汇总了PHP中sugar_file_get_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP sugar_file_get_contents函数的具体用法?PHP sugar_file_get_contents怎么用?PHP sugar_file_get_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sugar_file_get_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: serve

 /**
  * Serves the Soap Request
  * @return
  */
 public function serve()
 {
     ob_clean();
     global $HTTP_RAW_POST_DATA;
     $GLOBALS['log']->debug("I am here1 " . $HTTP_RAW_POST_DATA);
     $qs = '';
     if (isset($_SERVER['QUERY_STRING'])) {
         $qs = $_SERVER['QUERY_STRING'];
     } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
         $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
     } else {
         $qs = '';
     }
     if (stristr($qs, 'wsdl') || $HTTP_RAW_POST_DATA == '') {
         $wsdlCacheFile = $this->getWSDLPath(false);
         if (stristr($qs, 'wsdl')) {
             $contents = @sugar_file_get_contents($wsdlCacheFile);
             if ($contents !== false) {
                 header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
                 print $contents;
             }
             // if
         } else {
             $this->nusoap_server->service($HTTP_RAW_POST_DATA);
         }
         // else
     } else {
         $this->server->handle();
     }
     ob_end_flush();
     flush();
 }
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:36,代码来源:PHP5Soap.php

示例2: array

 * 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/';
                    $subject = @sugar_file_get_contents($custom_lang_file);
                    $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');
$default_versions[] = array('name' => 'Rebuild Relationships', 'db_version' => '4.0.0', 'file_version' => '4.0.0');
$default_versions[] = array('name' => 'Rebuild Extensions', 'db_version' => '4.0.0', 'file_version' => '4.0.0');
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:31,代码来源:DefaultVersions.php

示例3: disc_client_get_zip

function disc_client_get_zip($soapclient, $session, $verbose = false, $attempts = 0, $force_md5_sync = false)
{
    $max_attempts = 3;
    global $sugar_config, $timedate;
    // files might be big
    ini_set("memory_limit", "-1");
    set_time_limit(3600);
    ini_set('default_socket_timeout', 3600);
    $return_str = "";
    //1) rather than using md5, we will use the date_modified
    if (file_exists('modules/Sync/file_config.php') && $force_md5_sync != true) {
        require_once 'modules/Sync/file_config.php';
        global $file_sync_info;
        if (!isset($file_sync_info['last_local_sync']) && !isset($file_sync_info['last_server_sync'])) {
            $last_server_sync = $last_local_sync = $timedate->nowDb();
            $is_first_sync = true;
        } else {
            $last_local_sync = $file_sync_info['last_local_sync'];
            $last_server_sync = $file_sync_info['last_server_sync'];
            $is_first_sync = false;
        }
    } else {
        $last_server_sync = $last_local_sync = $timedate->nowDb();
        $is_first_sync = true;
    }
    $tempdir = create_cache_directory("disc_client");
    $temp_file = tempnam($tempdir, "sug");
    $file_list = array();
    if (!$is_first_sync) {
        $all_src_files = findAllTouchedFiles(".", array(), $last_local_sync);
        foreach ($all_src_files as $src_file) {
            $file_list[$src_file] = $src_file;
        }
    } else {
        $all_src_files = findAllFiles(".", array());
        require "install/data/disc_client.php";
        foreach ($all_src_files as $src_file) {
            foreach ($disc_client_ignore as $ignore_pattern) {
                if (!preg_match("#" . $ignore_pattern . "#", $src_file)) {
                    $md5 = md5_file($src_file);
                    $file_list[$src_file] = $md5;
                }
            }
        }
    }
    //2) save the list of md5 files to file system
    if (!write_array_to_file("client_file_list", $file_list, $temp_file)) {
        echo "Could not save file.";
    }
    // read file
    $contents = sugar_file_get_contents($temp_file);
    $md5 = md5($contents);
    // encode data
    $data = base64_encode($contents);
    $md5file = array('filename' => $temp_file, 'md5' => $md5, 'data' => $data, 'error' => null);
    $result = $soapclient->call('get_encoded_zip_file', array('session' => $session, 'md5file' => $md5file, 'last_sync' => $last_server_sync, 'is_md5_sync' => $is_first_sync));
    //3) at this point we could have the zip file
    $zip_file = tempnam($tempdir, "zip") . '.zip';
    if (isset($result['result']) && !empty($result['result'])) {
        $fh = sugar_fopen($zip_file, 'w');
        fwrite($fh, base64_decode($result['result']));
        fclose($fh);
        unzip($zip_file, ".", true);
    }
    if (file_exists($zip_file)) {
        unlink($zip_file);
    }
    $file_sync_info['last_local_sync'] = $timedate->nowDb();
    $server_time = $soapclient->call('get_gmt_time', array());
    $file_sync_info['last_server_sync'] = $server_time;
    $file_sync_info['is_first_sync'] = $is_first_sync;
    write_array_to_file('file_sync_info', $file_sync_info, 'modules/Sync/file_config.php');
    echo "File sync complete.";
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:74,代码来源:disc_client_utils.php

示例4: get_document_revision

/**
 * This method is used as a result of the .htaccess lock down on the cache directory. It will allow a
 * properly authenticated user to download a document that they have proper rights to download.
 *
 * @param String $session -- Session ID returned by a previous call to login.
 * @param String $id      -- ID of the document revision to obtain
 * @return return_document_revision - this is a complex type as defined in SoapTypes.php
 */
function get_document_revision($session, $id)
{
    global $sugar_config;
    $error = new SoapError();
    if (!validate_authenticated($session)) {
        $error->set_error('invalid_login');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
    $dr = new DocumentRevision();
    $dr->retrieve($id);
    if (!empty($dr->filename)) {
        $filename = "upload://{$dr->id}";
        $contents = base64_encode(sugar_file_get_contents($filename));
        return array('document_revision' => array('id' => $dr->id, 'document_name' => $dr->document_name, 'revision' => $dr->revision, 'filename' => $dr->filename, 'file' => $contents), 'error' => $error->get_soap_array());
    } else {
        $error->set_error('no_records');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
}
开发者ID:sunmo,项目名称:snowlotus,代码行数:27,代码来源:SoapSugarUsers.php

示例5: doSearch

function doSearch($index, $queryString, $start = 0, $amount = 20)
{
    global $current_user;
    $cachePath = 'cache/modules/AOD_Index/QueryCache/' . md5($queryString);
    if (is_file($cachePath)) {
        $mTime = getCorrectMTime($cachePath);
        if ($mTime > time() - 5 * 60) {
            $hits = unserialize(sugar_file_get_contents($cachePath));
        }
    }
    if (!isset($hits)) {
        $tmphits = $index->find($queryString);
        $hits = array();
        foreach ($tmphits as $hit) {
            $bean = BeanFactory::getBean($hit->record_module, $hit->record_id);
            if (empty($bean)) {
                continue;
            }
            if ($bean->bean_implements('ACL') && !is_admin($current_user)) {
                //Annoyingly can't use the following as it always passes true for is_owner checks on list
                //$bean->ACLAccess('list');
                $in_group = SecurityGroup::groupHasAccess($bean->module_dir, $bean->id, 'list');
                $is_owner = $bean->isOwner($current_user->id);
                $access = ACLController::checkAccess($bean->module_dir, 'list', $is_owner, 'module', $in_group);
                if (!$access) {
                    continue;
                }
            }
            $newHit = new stdClass();
            $newHit->record_module = $hit->record_module;
            $newHit->record_id = $hit->record_id;
            $newHit->score = $hit->score;
            $newHit->label = getModuleLabel($bean->module_name);
            $newHit->name = $bean->get_summary_text();
            $newHit->summary = getRecordSummary($bean);
            $newHit->date_entered = $bean->date_entered;
            $newHit->date_modified = $bean->date_modified;
            $hits[] = $newHit;
        }
        //Cache results so pagination is nice and snappy.
        cacheQuery($queryString, $hits);
    }
    $total = count($hits);
    $hits = array_slice($hits, $start, $amount);
    $res = array('total' => $total, 'hits' => $hits);
    return $res;
}
开发者ID:NALSS,项目名称:SuiteCRM,代码行数:47,代码来源:UnifiedSearch.php

示例6: get_encoded_portal_zip_file

function get_encoded_portal_zip_file($session, $md5file, $last_sync, $is_md5_sync = 1)
{
    // files might be big
    global $sugar_config;
    ini_set("memory_limit", "-1");
    $md5 = "";
    $data = "";
    $error = new SoapError();
    $the_error = "";
    if (!validate_authenticated($session)) {
        $the_error = "Invalid session";
    }
    require "install/data/disc_client.php";
    $tempdir_parent = create_cache_directory("disc_client");
    $temp_dir = tempnam($tempdir_parent, "sug");
    sugar_mkdir($temp_dir, 0775);
    $temp_file = tempnam($temp_dir, "sug");
    write_encoded_file($md5file, $temp_dir, $temp_file);
    $ignore = false;
    //generate md5 files on server
    require_once $temp_file;
    $server_files = array();
    // used later for removing unneeded local files
    $zip_file = tempnam(tempdir_parent, $session);
    $root_files = array();
    $custom_files = array();
    $file_list = array();
    if (!$is_md5_sync) {
        if (is_dir("portal")) {
            $root_files = findAllTouchedFiles("portal", array(), $last_sync);
        }
        if (is_dir("custom/portal")) {
            $custom_files = findAllTouchedFiles("custom/portal", array(), $last_sync);
        }
        $all_src_files = array_merge($root_files, $custom_files);
        foreach ($all_src_files as $src_file) {
            $ignore = false;
            foreach ($disc_client_ignore as $ignore_pattern) {
                if (preg_match("#" . $ignore_pattern . "#", $src_file)) {
                    $ignore = true;
                }
            }
            if (!$ignore) {
                //we have to strip off portal or custom/portal before the src file to look it up
                $key = str_replace('custom/portal/', '', $src_file);
                $key = str_replace('portal/', '', $key);
                if ($client_file_list != null && isset($client_file_list[$key])) {
                    //we have found a file out of sync
                    $file_list[] = $src_file;
                    //since we have processed this element of the client
                    //list of files, remove it from the list
                    unset($client_file_list[$key]);
                } else {
                    //this file does not exist on the client side
                    $file_list[] = $src_file;
                }
            }
        }
    } else {
        if (is_dir("portal")) {
            $root_files = findAllFiles("portal", array());
        }
        if (is_dir("custom/portal")) {
            $custom_files = findAllFiles("custom/portal", array());
        }
        $all_src_files = array_merge($root_files, $custom_files);
        foreach ($all_src_files as $src_file) {
            $ignore = false;
            foreach ($disc_client_ignore as $ignore_pattern) {
                if (preg_match("#" . $ignore_pattern . "#", $src_file)) {
                    $ignore = true;
                }
            }
            if (!$ignore) {
                $value = md5_file($src_file);
                //we have to strip off portal or custom/portal before the src file to look it up
                $key = str_replace('custom/portal/', '', $src_file);
                $key = str_replace('portal/', '', $key);
                if ($client_file_list != null && isset($client_file_list[$key])) {
                    if ($value != $client_file_list[$key]) {
                        //we have found a file out of sync
                        $file_list[] = $src_file;
                        //since we have processed this element of the client
                        //list of files, remove it from the list
                    }
                    unset($client_file_list[$key]);
                } else {
                    //this file does not exist on the client side
                    $file_list[] = $src_file;
                }
            }
        }
    }
    zip_files_list($zip_file, $file_list, '|.*portal/|');
    $contents = sugar_file_get_contents($zip_file);
    // encode data
    $data = base64_encode($contents);
    unlink($zip_file);
    return array('result' => $data, 'error' => $error->get_soap_array());
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:100,代码来源:SoapUpgradeUtils.php

示例7: updateFiles

 /**
  * Shows a list of files that might need manual updating
  *
  * @param string $searchString
  * @param string $oldKey
  * @return bool
  */
 private function updateFiles($newKey, $oldKey)
 {
     $matches = array();
     if (empty($newKey) || in_array($oldKey, $this->customListNames)) {
         return false;
     }
     $searchString1 = "'" . $oldKey . "'";
     $searchString2 = '"' . $oldKey . '"';
     foreach ($this->customOtherFileList as $fileName) {
         $text = sugar_file_get_contents($fileName);
         if (strpos($text, $searchString1) !== FALSE || strpos($text, $searchString2) !== FALSE) {
             $oldText = array("=> '{$oldKey}'", "=> \"{$oldKey}\"", "=>'{$oldKey}'", "=>\"{$oldKey}\"", "= '{$oldKey}'", "= \"{$oldKey}\"", "='{$oldKey}'", "=\"{$oldKey}\"");
             $newText = array("=> '{$newKey}'", "=> \"{$newKey}\"", "=>'{$newKey}'", "=>\"{$newKey}\"", "= '{$newKey}'", "= \"{$newKey}\"", "='{$newKey}'", "=\"{$newKey}\"");
             $text = str_replace($oldText, $newText, $text);
             if (strpos($text, $searchString1) !== FALSE) {
                 $matches[$fileName] = true;
                 $this->customListNames[] = $oldKey;
             } else {
                 $this->modifiedFiles[$fileName] = $this->truncateFileName($fileName);
                 $this->backupFile($fileName);
                 sugar_file_put_contents($fileName, $text, LOCK_EX);
             }
         }
     }
     if (!empty($matches)) {
         $this->logThis("------------------------------------------------------------", self::SEV_MEDIUM);
         $this->logThis("These files MAY need to be updated to reflect the new key (New '{$newKey}' vs. old '{$oldKey}')", self::SEV_MEDIUM);
         $this->logThis("-------------------------------------------------------------", self::SEV_MEDIUM);
         foreach ($matches as $fileName => $flag) {
             $this->manualFixFiles[$fileName] = $this->truncateFileName($fileName);
             $this->logThis($this->truncateFileName($fileName), self::SEV_MEDIUM);
         }
         $this->logThis("-------------------------------------------------------------", self::SEV_MEDIUM);
     }
 }
开发者ID:kbrill,项目名称:sugarcrm-tools,代码行数:42,代码来源:fixLanguageFiles.php

示例8: getLicenseDisplay

 /**
  * A Static method used to obtain the div for the license
  *
  * @param String license_file - the path to the license file
  * @param String form_action - the form action when accepting the license file
  * @param String next_step - the value for the next step in the installation process
  * @param String zipFile - a string representing the path to the zip file
  * @param String type - module/patch....
  * @param String manifest - the path to the manifest file
  * @param String modify_field - the field to update when the radio button is changed
  * @return String - a form used to display the license
  */
 function getLicenseDisplay($license_file, $form_action, $next_step, $zipFile, $type, $manifest, $modify_field)
 {
     global $current_language;
     $mod_strings = return_module_language($current_language, "Administration");
     $contents = sugar_file_get_contents($license_file);
     $div_id = urlencode($zipFile);
     $display = "<form name='delete{$zipFile}' action='{$form_action}' method='POST'>";
     $display .= "<input type='hidden' name='current_step' value='{$next_step}'>";
     $display .= "<input type='hidden' name='languagePackAction' value='{$type}'>";
     $display .= "<input type='hidden' name='manifest' value='\".urlencode({$manifest}).\"'>";
     $display .= "<input type='hidden' name='zipFile' value='\".urlencode({$zipFile}).\"'>";
     $display .= "<table><tr>";
     $display .= "<td align=\"left\" valign=\"top\" colspan=2>";
     $display .= "<b><font color='red' >{$mod_strings['LBL_MODULE_LICENSE']}</font></b>";
     $display .= "</td>";
     $display .= "<td>";
     $display .= "<slot><a class=\"listViewTdToolsS1\" id='href_animate' onClick=\"PackageManager.toggleLowerDiv('span_animate_div_{$div_id}', 'span_license_div_{$div_id}', 350, 0);\"><span id='span_animate_div_{$div_id}'<img src='" . SugarThemeRegistry::current()->getImageURL('advanced_search.gif') . "' width='8' height='8' alt='Advanced' border='0'>&nbsp;Expand</span></a></slot></td>";
     $display .= "</td>";
     $display .= "</tr>";
     $display .= "</table>";
     $display .= "<div id='span_license_div_{$div_id}' style=\"display: none;\">";
     $display .= "<table>";
     $display .= "<tr>";
     $display .= "<td align=\"left\" valign=\"top\" colspan=2>";
     $display .= "<textarea cols=\"100\" rows=\"8\">{$contents}</textarea>";
     $display .= "</td>";
     $display .= "</tr>";
     $display .= "<tr>";
     $display .= "<td align=\"left\" valign=\"top\" colspan=2>";
     $display .= "<input type='radio' id='radio_license_agreement_accept' name='radio_license_agreement' value='accept' onClick=\"document.getElementById('{$modify_field}').value = 'yes';\">{$mod_strings['LBL_ACCEPT']}&nbsp;";
     $display .= "<input type='radio' id='radio_license_agreement_reject' name='radio_license_agreement' value='reject' checked onClick=\"document.getElementById('{$modify_field}').value = 'no';\">{$mod_strings['LBL_DENY']}";
     $display .= "</td>";
     $display .= "</tr>";
     $display .= "</table>";
     $display .= "</div>";
     $display .= "</form>";
     return $display;
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:50,代码来源:PackageManagerDisplay.php

示例9: count

                echo $mod_strings['LBL_UW_PATCH_READY'];
            }
        }
    }
} else {
    echo $mod_strings['LBL_UW_PATCH_READY2'];
    echo '<input type="checkbox" onclick="toggle_these(0, ' . count($new_studio_mod_files) . ', this)"> ' . $mod_strings['LBL_UW_CHECK_ALL'];
    foreach ($new_studio_mod_files as $the_file) {
        $new_file = clean_path("{$zip_to_dir}/{$the_file}");
        print "<li><input id=\"copy_{$count}\" name=\"copy_{$count}\" type=\"checkbox\" value=\"" . $the_file . "\"> " . $new_file . "</li>";
        $count++;
    }
}
echo '<br>';
if ($require_license) {
    $contents = sugar_file_get_contents($license_file);
    $readme_contents = '';
    if ($found_readme) {
        if (file_exists($readme_file) && filesize($readme_file) > 0) {
            $readme_contents = file_get_contents($readme_file);
        } elseif (!empty($manifest['readme'])) {
            $readme_contents = $manifest['readme'];
        }
    }
    $license_final = <<<eoq2
\t<table width='100%'>
\t<tr>
\t<td colspan="3"><ul class="tablist">
\t<li id="license_li" class="active"><a id="license_link"  class="current" href="javascript:selectTabCSS('license');">{$mod_strings['LBL_LICENSE']}</a></li>
\t<li class="active" id="readme_li"><a id="readme_link" href="javascript:selectTabCSS('readme');">{$mod_strings['LBL_README']}</a></li>
\t</ul></td>
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:31,代码来源:UpgradeWizard_prepare.php

示例10: run_sql_file

/**
 * @deprecated
 * @todo this function is only used by one function ( run_upgrade_wizard_sql() ), which isn't
 *       used either; trying kill this off
 */
function run_sql_file($filename)
{
    if (!is_file($filename)) {
        print "Could not find file: {$filename} <br>";
        return false;
    }
    $contents = sugar_file_get_contents($filename);
    $lastsemi = strrpos($contents, ';');
    $contents = substr($contents, 0, $lastsemi);
    $queries = explode(';', $contents);
    $db = DBManagerFactory::getInstance();
    foreach ($queries as $query) {
        if (!empty($query)) {
            if ($db->dbType == 'oci8') {
            } else {
                $db->query($query . ';', true, "An error has occured while running.<br>");
            }
        }
    }
    return true;
}
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:26,代码来源:db_utils.php

示例11: load_file

 /**
  * Load a configuration file manually.
  *
  * @param string $file_name file name to load
  * @param boolean $prepend_path whether current config path should be
  *                              prepended to the filename
  */
 function load_file($file_name, $prepend_path = true)
 {
     if ($prepend_path && $this->_config_path != "") {
         $config_file = $this->_config_path . $file_name;
     } else {
         $config_file = $file_name;
     }
     ini_set('track_errors', true);
     $contents = @sugar_file_get_contents($config_file);
     if ($contents === false) {
         $this->_trigger_error_msg("Could not open config file '{$config_file}'");
         return false;
     }
     $this->_config_data[$config_file] = $this->parse_contents($contents);
     return true;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:23,代码来源:Config_File.class.php

示例12: get_document_revision

/**
 * This method is used as a result of the .htaccess lock down on the cache directory. It will allow a
 * properly authenticated user to download a document that they have proper rights to download.
 *
 * @param String $session -- Session ID returned by a previous call to login.
 * @param String $id      -- ID of the document revision to obtain
 * @return return_document_revision - this is a complex type as defined in SoapTypes.php
 */
function get_document_revision($session, $id)
{
    global $sugar_config;
    $error = new SoapError();
    if (!validate_authenticated($session)) {
        $error->set_error('invalid_login');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
    $dr = new DocumentRevision();
    $dr->retrieve($id);
    if (!empty($dr->filename)) {
        $filename = $sugar_config['upload_dir'] . "/" . $dr->id;
        $contents = base64_encode(sugar_file_get_contents($filename));
        //        $fh = sugar_fopen($sugar_config['upload_dir']."/rogerrsmith.doc", 'w');
        //        fwrite($fh, base64_decode($contents));
        return array('document_revision' => array('id' => $dr->id, 'document_name' => $dr->document_name, 'revision' => $dr->revision, 'filename' => $dr->filename, 'file' => $contents), 'error' => $error->get_soap_array());
    } else {
        $error->set_error('no_records');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
}
开发者ID:nartnik,项目名称:sugarcrm_test,代码行数:29,代码来源:SoapSugarUsers.php

示例13: debugPdfCreation

function debugPdfCreation($filename)
{
    $pdfLatexDir = dirname($filename);
    $pdfLatexArgs = '-interaction=nonstopmode -output-directory=' . $pdfLatexDir . ' ' . $filename . ' 2>&1';
    $pdfTestArgs = '-version';
    $returnTestValue = null;
    $consoleOutput = array();
    //try to use value from config file first
    $defaultPath = PDFLATEX;
    $found = '';
    $addString = '';
    $filenameWithoutExtension = str_replace("\\", "/", $pdfLatexDir . DIRECTORY_SEPARATOR . basename($filename, '.tmp'));
    $pdfFilename = $filenameWithoutExtension . '.pdf';
    $returnTestValue = execute(PDFLATEX, $pdfTestArgs, $consoleOutput);
    if ($returnTestValue === 0) {
        $addString = "\npdflatex file is found at location entered in config file.\n";
        if (!empty($consoleOutput)) {
            $addString .= "pdflatex -version output: \n\r" . implode("\n", $consoleOutput);
        } else {
            $addString .= "\npdflatex -version output: null";
        }
    } else {
        $addString = "\npdflatex executable is not found at default location, trying to find it at some other locations\n";
        $defaultPath = DIRECTORY_SEPARATOR . 'usr' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'pdflatex';
        $defaultTexName = 'pdflatex';
        if (strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN') {
            $defaultTexName = 'pdflatex.exe';
            $defaultPath = 'C:/Program Files/MiKTeX 2.9/miktex/bin/pdflatex.exe';
        } elseif (strtoupper(substr(php_uname('s'), 0, 3)) === 'DAR') {
            $defaultPath = '/usr/texbin/pdflatex';
        }
        if (file_exists($defaultPath)) {
            //$addString .= "pdflatex file is found at location {$defaultPath} that is different to one in Your config file. Modify config file and re-run pdf creation\n";
            $found = $defaultPath;
        } else {
            //try more complicated search
            $apachePath = getenv('PATH');
            $addString .= "Trying paths in PATH variable: {$apachePath}\n";
            //$GLOBALS['log']->error('latexToPdf: $PATH variable is ' . getenv('PATH'));
            $paths = explode(PATH_SEPARATOR, $apachePath);
            foreach ($paths as $p) {
                $fullname = $p . DIRECTORY_SEPARATOR . $defaultTexName;
                $addString .= "Looking for pdflatex at: {$fullname}\n";
                //$GLOBALS['log']->error('latexToPdf: looking for pdflatex at ' . $fullname);
                if (is_file($fullname)) {
                    $found = $fullname;
                    break;
                }
            }
        }
        if ($found) {
            //check if we found correct file
            $defaultPath = $found;
            $addString .= "pdflatex file is found at location {$defaultPath} that is different to one in Your config file. Modify config file and re-run pdf creation\n";
            $consoleOutput = array();
            $returnTestValue = execute($defaultPath, $pdfTestArgs, $consoleOutput);
            if (!empty($consoleOutput) && $returnTestValue === 0) {
                $addString .= "pdflatex -version output: \n" . implode("\n", $consoleOutput);
            } else {
                $addString .= "npdflatex -version output: null.\nThere still is problem with running of pdflatex; check file permissions.\n";
                sugar_file_put_contents($filename, $addString, FILE_APPEND | LOCK_EX);
                //Rewrite old log file
                rename($filename, $filenameWithoutExtension . '.log');
                return $filenameWithoutExtension . '.log';
            }
        } else {
            $addString .= "Most likely You do not have pdflatex package installed\n";
            sugar_file_put_contents($filename, $addString, FILE_APPEND | LOCK_EX);
            //Rewrite old log file
            rename($filename, $filenameWithoutExtension . '.log');
            return $filenameWithoutExtension . '.log';
        }
    }
    if (CENTOS_PATCH) {
        putenv('HOME=/tmp/');
    }
    $consoleOutput = array();
    $returnValue = execute($defaultPath, $pdfLatexArgs, $consoleOutput);
    if (!empty($consoleOutput)) {
        $addString .= "\n\rBELOW IS CONSOLE OUTPUT OF PDFLATEX RUN:\n\r" . implode("\n", $consoleOutput);
    } else {
        $addString .= "\n\rConsole output is empty for some reason.";
    }
    if (file_exists($filenameWithoutExtension . '.log')) {
        $addString .= "\n\rBELOW IS LOG FILE OF PDFLATEX RUN: \n\r" . sugar_file_get_contents($filenameWithoutExtension . '.log');
    } else {
        $addString .= "\n\rLog file does not exists";
    }
    sugar_file_put_contents($filename, $addString, FILE_APPEND | LOCK_EX);
    //Rewrite old log file
    rename($filename, $filenameWithoutExtension . '.log');
    return $filenameWithoutExtension . '.log';
}
开发者ID:santara12,项目名称:OpenQuotesAndContracts,代码行数:93,代码来源:Common.php

示例14: executePreparedQuery

 /**
  * Takes a prepared stmt index and the data to replace and creates the query and runs it.
  *
  * @param  int		$stmt       The index of the prepared statement from preparedTokens
  * @param  array    $data 		The array of data to replace the tokens with.
  * @return resource result set or false on error
  */
 public function executePreparedQuery($stmt, $data = array())
 {
     if (!empty($this->preparedTokens[$stmt])) {
         if (!is_array($data)) {
             $data = array($data);
         }
         $pTokens = $this->preparedTokens[$stmt];
         //ensure that the number of data elements matches the number of replacement tokens
         //we found in prepare().
         if (count($data) != $pTokens['tokenCount']) {
             //error the data count did not match the token count
             return false;
         }
         $query = '';
         $dataIndex = 0;
         $tokens = $pTokens['tokens'];
         foreach ($tokens as $val) {
             switch ($val) {
                 case '?':
                     $query .= $this->quote($data[$dataIndex++]);
                     break;
                 case '&':
                     $filename = $data[$dataIndex++];
                     $query .= sugar_file_get_contents($filename);
                     break;
                 case '!':
                     $query .= $data[$dataIndex++];
                     break;
                 default:
                     $query .= $val;
                     break;
             }
             //switch
         }
         //foreach
         return $this->query($query);
     } else {
         return false;
     }
 }
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:47,代码来源:DBManager.php

示例15: cacheXTPL

 function cacheXTPL($file, $cache_file, $preview_file = false)
 {
     global $beanList;
     //now if we have a backup_file lets use that instead of the original
     if ($preview_file) {
         $file = $preview_file;
     }
     if (!isset($the_module)) {
         $the_module = $_SESSION['studio']['module'];
     }
     $files = StudioParser::getFiles($the_module);
     $xtpl = $files[$_SESSION['studio']['selectedFileId']]['php_file'];
     $originalFile = $files[$_SESSION['studio']['selectedFileId']]['template_file'];
     $type = StudioParser::getFileType($files[$_SESSION['studio']['selectedFileId']]['type']);
     $buffer = sugar_file_get_contents($xtpl);
     $cache_file = create_cache_directory('studio/' . $file);
     $xtpl_cache = create_cache_directory('studio/' . $xtpl);
     $module = $this->workingModule;
     $form_string = "require_once('modules/" . $module . "/Forms.php');";
     if ($type == 'edit' || $type == 'detail') {
         if (empty($_REQUEST['record'])) {
             $buffer = preg_replace('(\\$xtpl[\\ ]*=)', "\$focus->assign_display_fields('{$module}'); \$0", $buffer);
         } else {
             $buffer = preg_replace('(\\$xtpl[\\ ]*=)', "\$focus->retrieve('" . $_REQUEST['record'] . "');\n\$focus->assign_display_fields('{$module}');\n \$0", $buffer);
         }
     }
     $_REQUEST['query'] = true;
     if (substr_count($file, 'SearchForm') > 0) {
         $temp_xtpl = new XTemplate($file);
         if ($temp_xtpl->exists('advanced')) {
             global $current_language;
             $mods = return_module_language($current_language, 'DynamicLayout');
             $mod = BeanFactory::getBean($module);
             $this->populateRequestFromBuffer($file);
             $mod->assign_display_fields($module);
             $buffer = str_replace(array('echo $lv->display();', '$search_form->parse("advanced");', '$search_form->out("advanced");', '$search_form->parse("main");', '$search_form->out("main");'), '', $buffer);
             $buffer = str_replace('echo get_form_footer();', '$search_form->parse("main");' . "\n" . '$search_form->out("main");' . "\necho '<br><b>" . translate('LBL_ADVANCED', 'DynamicLayout') . "</b><br>';" . '$search_form->parse("advanced");' . "\n" . '$search_form->out("advanced");' . "\n \$sugar_config['list_max_entries_per_page'] = 1;", $buffer);
         }
     } else {
         if ($type == 'detail') {
             $buffer = str_replace('header(', 'if(false) header(', $buffer);
         }
     }
     $buffer = str_replace($originalFile, $cache_file, $buffer);
     $buffer = "<?php\n\$sugar_config['list_max_entries_per_page'] = 1;\n ?>" . $buffer;
     $buffer = str_replace($form_string, '', $buffer);
     $buffer = $this->disableInputs($buffer);
     $xtpl_fp_cache = sugar_fopen($xtpl_cache, 'w');
     fwrite($xtpl_fp_cache, $buffer);
     fclose($xtpl_fp_cache);
     return $xtpl_cache;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:52,代码来源:StudioParser.php


注:本文中的sugar_file_get_contents函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。