From: <tim...@us...> - 2010-05-02 10:25:55
|
Revision: 3438 http://web-erp.svn.sourceforge.net/web-erp/?rev=3438&view=rev Author: tim_schofield Date: 2010-05-02 10:25:49 +0000 (Sun, 02 May 2010) Log Message: ----------- Tim: Updates for case where no internet connection is present Modified Paths: -------------- trunk/doc/Change.log.html trunk/includes/MiscFunctions.php trunk/includes/footer.inc trunk/includes/session.inc Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-02 10:12:10 UTC (rev 3437) +++ trunk/doc/Change.log.html 2010-05-02 10:25:49 UTC (rev 3438) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>02/05/10 Tim: Updates for case where no internet connection is present</p> <p>02/05/10 Tim: SelectProduct.php - Correctly show the next page of products in a search.</p> <p>01/05/10 Lindsay: Install now includes an option to install a logo.jpg file</p> <p>30/04/10 Lindsay: Make installation operation functional again</p> Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2010-05-02 10:12:10 UTC (rev 3437) +++ trunk/includes/MiscFunctions.php 2010-05-02 10:25:49 UTC (rev 3438) @@ -104,7 +104,8 @@ function GetECBCurrencyRates () { /* See http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html for detail of the European Central Bank rates - published daily */ - if ($xml = file_get_contents('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml')) { + if (file_exists('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml')) { + $xml = file_get_contents('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml'); $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); @@ -140,6 +141,8 @@ $Currencies['EUR']=1; //ECB delivers no rate for Euro //return an array of the currencies and rates return $Currencies; + } else { + return false; } } @@ -162,14 +165,16 @@ } function quote_oanda_currency($CurrCode) { - $page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $CurrCode . '&format=CSV&dest=Get+Table&sel_list=' . $_SESSION['CompanyRecord']['currencydefault']); - $match = array(); - preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', implode('', $page), $match); + if (file_exists('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $CurrCode . '&format=CSV&dest=Get+Table&sel_list=' . $_SESSION['CompanyRecord']['currencydefault'])) { + $page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $CurrCode . '&format=CSV&dest=Get+Table&sel_list=' . $_SESSION['CompanyRecord']['currencydefault']); + $match = array(); + preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', implode('', $page), $match); - if ( sizeof($match) > 0 ){ - return $match[3]; - } else { - return false; + if ( sizeof($match) > 0 ){ + return $match[3]; + } else { + return false; + } } } Modified: trunk/includes/footer.inc =================================================================== --- trunk/includes/footer.inc 2010-05-02 10:12:10 UTC (rev 3437) +++ trunk/includes/footer.inc 2010-05-02 10:25:49 UTC (rev 3438) @@ -25,10 +25,8 @@ echo '<tr><td class="footer">webERP ' . _('Copyright') . ' © weberp.org - '.date('Y').'</td></tr>'; - if(isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on'){ + if(file_exists('http://sflogo.sourceforge.net/sflogo.php')) { echo '<tr><td class="footer"><a href="https://sourceforge.net/projects/web-erp"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=70949&type=12" width="120" height="30" border="0" alt="Get webERP web-based ERP Accounting at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a></td></tr>'; - } else { - echo '<tr><td class="footer"><a href="http://sourceforge.net/projects/web-erp"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=70949&type=12" width="120" height="30" border="0" alt="Get webERP web-based ERP Accounting at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a></td></tr>'; } echo '</table>'; Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2010-05-02 10:12:10 UTC (rev 3437) +++ trunk/includes/session.inc 2010-05-02 10:25:49 UTC (rev 3438) @@ -134,16 +134,18 @@ $CurrencyRates = GetECBCurrencyRates(); // gets rates from ECB see includes/MiscFunctions.php /*Loop around the defined currencies and get the rate from ECB */ - $CurrenciesResult = DB_query('SELECT currabrev FROM currencies',$db); - while ($CurrencyRow = DB_fetch_row($CurrenciesResult)){ - if ($CurrencyRow[0]!=$_SESSION['CompanyRecord']['currencydefault']){ - $UpdateCurrRateResult = DB_query('UPDATE currencies SET + if ($CurrencyRates!=false) { + $CurrenciesResult = DB_query('SELECT currabrev FROM currencies',$db); + while ($CurrencyRow = DB_fetch_row($CurrenciesResult)){ + if ($CurrencyRow[0]!=$_SESSION['CompanyRecord']['currencydefault']){ + $UpdateCurrRateResult = DB_query('UPDATE currencies SET rate=' . GetCurrencyRate ($CurrencyRow[0],$CurrencyRates) . " WHERE currabrev='" . $CurrencyRow[0] . "'",$db); + } } + $_SESSION['UpdateCurrencyRatesDaily'] = Date('Y-m-d'); + $UpdateConfigResult = DB_query("UPDATE config SET confvalue = '" . Date('Y-m-d') . "' WHERE confname='UpdateCurrencyRatesDaily'",$db); } - $_SESSION['UpdateCurrencyRatesDaily'] = Date('Y-m-d'); - $UpdateConfigResult = DB_query("UPDATE config SET confvalue = '" . Date('Y-m-d') . "' WHERE confname='UpdateCurrencyRatesDaily'",$db); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |