AAAAindex.html000066600000000000151373200240006530 0ustar00convertECB.php000066600000014676151373200240007266 0ustar00lifetime; $cache->setLifeTime(86400/4); // check 4 time per day // save cache conf $conf = JFactory::getConfig(); // check if cache is enabled in configuration $cacheactive = $conf->getValue('config.caching'); $cache->setCaching(1); //enable caching $globalCurrencyConverter = $cache->call( array( 'convertECB', 'getSetExchangeRates' ),$this->document_address ); // revert configuration $cache->setCaching($cacheactive); if(!$globalCurrencyConverter ){ //vmdebug('convert convert No $globalCurrencyConverter convert '.$amountA); return $amountA; } else { $valA = isset( $globalCurrencyConverter[$currA] ) ? $globalCurrencyConverter[$currA] : 1.0; $valB = isset( $globalCurrencyConverter[$currB] ) ? $globalCurrencyConverter[$currB] : 1.0; $val = (float)$amountA * (float)$valB / (float)$valA; //vmdebug('convertECB with '.$currA.' '.$amountA.' * '.$valB.' / '.$valA.' = '.$val,$globalCurrencyConverter[$currA]); return $val; } } static function getSetExchangeRates($ecb_filename){ $archive = true; setlocale(LC_TIME, "en-GB"); $now = time() + 3600; // Time in ECB (Germany) is GMT + 1 hour (3600 seconds) if (date("I")) { $now += 3600; // Adjust for daylight saving time } $weekday_now_local = gmdate('w', $now); // week day, important: week starts with sunday (= 0) !! $date_now_local = gmdate('Ymd', $now); $time_now_local = gmdate('Hi', $now); $time_ecb_update = '1415'; if( is_writable(JPATH_BASE.DS.'cache') ) { $store_path = JPATH_BASE.DS.'cache'; } else { $store_path = JPATH_SITE.DS.'media'; } $archivefile_name = $store_path.'/daily.xml'; $val = ''; if(file_exists($archivefile_name) && filesize( $archivefile_name ) > 0 ) { // timestamp for the Filename $file_datestamp = date('Ymd', filemtime($archivefile_name)); // check if today is a weekday - no updates on weekends if( date( 'w' ) > 0 && date( 'w' ) < 6 // compare filedate and actual date && $file_datestamp != $date_now_local // if localtime is greater then ecb-update-time go on to update and write files && $time_now_local > $time_ecb_update) { $curr_filename = $ecb_filename; } else { $curr_filename = $archivefile_name; $last_updated = $file_datestamp; $archive = false; } } else { $curr_filename = $ecb_filename; } if( !is_writable( $store_path )) { $archive = false; vmError( "The file $archivefile_name can't be created. The directory $store_path is not writable" ); } // JError::raiseNotice(1, "The file $archivefile_name should be in the directory $store_path " ); if( $curr_filename == $ecb_filename ) { // Fetch the file from the internet if(!class_exists('VmConnector')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'connection.php'); // JError::raiseNotice(1, "Updating currency " ); if (!$contents = VmConnector::handleCommunication( $curr_filename )) { if (isset($file_datestamp)) { $contents = @file_get_contents( $curr_filename ); } } else $last_updated = date('Ymd'); } else { $contents = @file_get_contents( $curr_filename ); } if( $contents ) { // if archivefile does not exist if( $archive ) { // now write new file file_put_contents( $archivefile_name, $contents ); } $contents = str_replace (" loadXML($contents) ) { //todo vmError('Failed to parse the Currency Converter XML document.'); vmError('The content: '.$contents); // $GLOBALS['product_currency'] = $vendor_currency; return false; } $currency_list = $xmlDoc->getElementsByTagName( "Cube" ); // Loop through the Currency List $length = $currency_list->length; for ($i = 0; $i < $length; $i++) { $currNode = $currency_list->item($i); if(!empty($currNode) && !empty($currNode->attributes->getNamedItem("currency")->nodeValue)){ $currency[$currNode->attributes->getNamedItem("currency")->nodeValue] = $currNode->attributes->getNamedItem("rate")->nodeValue; unset( $currNode ); } } $globalCurrencyConverter = $currency; } else { $globalCurrencyConverter = false; vmError( 'Failed to retrieve the Currency Converter XML document.'); // return false; } return $globalCurrencyConverter; } } // pure php no closing tag convertECB.xml000066600000001421151373200240007257 0ustar00 ECB Currency Converter 28. January 2008 GNU/GPL http://joomlacode.org/gf/project/jmart/ 1.0 Currency Converter Plugin, based on Rates from the European Central Bank convertECB convertECB.php .htaccess000066600000000177151373200240006350 0ustar00 Order allow,deny Deny from all