| | All rights reserved | +------------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "license.txt"| | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.magneticone.com/store/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT MAGNETICONE | | (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE. | | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Developer of the Code is MagneticOne, | | Copyright (C) 2006 All Rights Reserved. | +-----------------------------------------------------------------------------*/ // class for rss export class m1_rss extends oscm1_main { // list of supported export formats var $supported_formats = array (array('id' => 'rss_092', 'text' => 'RSS 0.92'), array('id' => 'rss_1', 'text' => 'RSS 1.0'), array('id' => 'rss_2', 'text' => 'RSS 2.0') ); function ReadConfig() { $this->options['export_format'] = $this->select_config_value('M1_RSS_EXPORT_FORMAT'); $this->options['export_languages'] = explode(',', $this->select_config_value('M1_RSS_EXPORT_LANGUAGE')); $this->options['export_categories'] = explode(',', $this->select_config_value('M1_RSS_EXPORT_CATEGORY')); return true; } function GetExportParams() { $this->options['export_format'] = $this->select_config_value('M1_RSS_EXPORT_FORMAT'); $this->options['export_languages'] = $this->select_config_value('M1_RSS_EXPORT_LANGUAGE'); $this->options['export_categories'] = $this->select_config_value('M1_RSS_EXPORT_CATEGORY'); } /** * Method to update configiguration of this contribution * * @param array $input * @return boolean */ function UpdateConfig($input) { // updating values for export format if (isset($input['export_format'])) { $this->update(M1_CONFIGURATION_VALUE_FIELD, $input['export_format'], M1_CONFIGURATION_KEY_FIELD . "='M1_RSS_EXPORT_FORMAT'"); } // updating values for export languages if (is_array($input['export_languages'])) { foreach ($input['export_languages'] as $k=>$v) { $input['export_languages'][$k] = $this->prepare_input($v); } $exp_lang = join(',', $input['export_languages']); } else { $exp_lang = ''; } $this->update(M1_CONFIGURATION_VALUE_FIELD, $exp_lang, M1_CONFIGURATION_KEY_FIELD . "='M1_RSS_EXPORT_LANGUAGE'"); // updating values for category languages if (is_array($input['export_categories'])) { foreach ($input['export_categories'] as $k=>$v) { $input['export_categories'][$k] = $this->prepare_input($v); } $exp_lang = join(',', $input['export_categories']); } else { $exp_lang = ''; } $this->update(M1_CONFIGURATION_VALUE_FIELD, $exp_lang, M1_CONFIGURATION_KEY_FIELD . "='M1_RSS_EXPORT_CATEGORY'"); $this->ReadConfig(); return true; } function GenerateFormat_rss_092() { Header('Content-Type: application/xml'); $generation_date = date(r); $rdf_about = $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"]; $generator_name = M1_RSS_GENERATOR_NAME; $this->export_general['weblink'] = str_replace('http://', '', $this->export_general['weblink']); $this->export_general['weblink'] = str_replace('https://', '', $this->export_general['weblink']); $export = ' 1440 ' . $this->cleanText($this->export_general['rss_title']) . ' http://' . $this->export_general['weblink'] . ' prepareCdata($this->export_general['description']) . ']]> prepareCdata($this->export_general['email_address']) . ']]> ' . $generation_date .' http://blogs.law.harvard.edu/tech/rss '; echo $export; if (is_array($this->export_products)) { foreach ($this->export_products as $k => $v) { $link = utf8_encode($this->format_product_url($k, $v['language_code'])); echo '' . "\n"; echo ' ' , $this->cleanText($v['name']) , '' . "\n"; echo ' ' , $this->cleanText($v['category_name']) , '' . "\n"; echo ' ' , $link , '' . "\n"; echo ' format_image_url($v['image']) . '" align="left" valign="top">'; } echo $this->prepareCdata($v['description']); echo ']]>' . "\n"; echo '' . "\n"; } } echo ""; echo ""; } function GenerateFormat_rss_1() { Header('Content-Type: application/xml'); $generation_date = date(r); $rdf_about = $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"]; $generator_name = M1_RSS_GENERATOR_NAME; $this->export_general['weblink'] = str_replace('http://', '', $this->export_general['weblink']); $this->export_general['weblink'] = str_replace('https://', '', $this->export_general['weblink']); $export = ' 1440 ' . $this->cleanText($this->export_general['rss_title']) . ' http://' . $this->export_general['weblink'] . ' prepareCdata($this->export_general['description']) . ']]> '; echo $export; if (is_array($this->export_products)) { echo ' '; foreach ($this->export_products as $k => $v) { $link = utf8_encode($this->format_product_url($k, $v['language_code'])); echo ' ' . "\n"; } echo ' '; } echo ''; if (is_array($this->export_products)) { foreach ($this->export_products as $k => $v) { $link = utf8_encode($this->format_product_url($k, $v['language_code'])); echo "\n"; echo ' ' , $this->cleanText($v['name']) , '' . "\n"; echo ' ' , $link , '' . "\n"; // echo "".utf8_encode(htmlspecialchars($v['language_code']))."\n"; echo ' format_image_url($v['image']) . '" align="left" valign="top">'; } echo $this->prepareCdata($v['description']); echo ']]>' . "\n"; echo '' . "\n"; } } echo ""; } function GenerateFormat_rss_2() { $generation_date = date(r); $rdf_about = $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"]; $generator_name = M1_RSS_GENERATOR_NAME; $this->export_general['weblink'] = str_replace('http://', '', $this->export_general['weblink']); $this->export_general['weblink'] = str_replace('https://', '', $this->export_general['weblink']); Header('Content-Type: application/xml'); $export = ' 1440 ' . $this->cleanText($this->export_general['rss_title']) . ' http://' . $this->export_general['weblink'] . ' prepareCdata($this->export_general['description']) . ']]> prepareCdata($this->export_general['email_address']) . ']]> prepareCdata($this->export_general['email_address']) . ']]> ' . $generation_date .' http://blogs.law.harvard.edu/tech/rss ' . $this->cleanText($generator_name) . ' '; echo $export; if (is_array($this->export_products)) { foreach ($this->export_products as $k => $v) { $link = utf8_encode($this->format_product_url($k, $v['language_code'])); echo '' . "\n"; $v['name'] = str_replace('
','',$v['name']); $v['name'] = str_replace('
','',$v['name']); $v['name'] = str_replace('
','',$v['name']); $v['name'] = str_replace('
','',$v['name']); $v['name'] = str_replace('color= ff0000','',$v['name']); $v['name'] = str_replace('','',$v['name']); $v['name'] = str_replace('','',$v['name']); $v['name'] = str_replace('','',$v['name']); $v['name'] = str_replace('','',$v['name']); $v['name'] = str_replace('','',$v['name']); echo ' ' , $this->cleanText($v['name']) , '' . "\n"; echo ' ' , $this->cleanText($v['category_name']) , '' . "\n"; echo ' ' , $link , '' . "\n"; echo ' ' , $link , '' . "\n"; echo ' format_image_url($v['image']) . '" align="left" valign="top">'; } echo $this->prepareCdata($v['description']); echo ']]>' . "\n"; echo '
' . "\n"; } } echo "
"; echo "
"; } /** * Cleans text of all formating and scripting code */ function cleanText ( $text ) { $text = htmlspecialchars( $text ); $text = preg_replace( "']*>.*?'si", '', $text ); $text = preg_replace( '/]*>([^<]+)<\/a>/is', '\2(\1)', $text ); $text = preg_replace( '//', '', $text ); $text = preg_replace( '/{.+?}/', '', $text ); $text = preg_replace( '/ /', ' ', $text ); $text = preg_replace( '/&/', ' ', $text ); $text = preg_replace( '/"/', ' ', $text ); $text = preg_replace( '
', '', $text ); $text = preg_replace( '
', '', $text ); $text = str_replace( '<', '', $text ); $text = str_replace( '>', '', $text ); $text = str_replace( '<>', '', $text ); $text = strip_tags( $text ); $text = $this->badChars($text); $text = htmlspecialchars( $text ); return utf8_encode(html_entity_decode($text)); } function prepareCdata($input) { return str_replace(']]>', '', $this->badChars($input)); // return $input; } function badChars ( $text ) { // return preg_replace('/[^a-zA-Z\-\.\_:0-9\xC0-\xFF@]+/', ' ', $text); return ereg_replace('([^[:print:]])', '', $text); } } // RSS class end ?>