[ Index ] |
PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 // Module/Plug-in Feed to Article import default settings 24 // Init used to import feed to articles 25 26 if(!empty($_getVar['feedimport'])) { 27 28 // catch the Feed to be imported to article 29 $feedimport_source = $_getVar['feedimport']; 30 $feedimport_where = "cnt_status=1 AND cnt_module='feedimport' AND "; 31 32 if(strlen($feedimport_source) > 32 && substr($feedimport_source, 32) == '-now') { 33 $feedimport_source = substr($feedimport_source, 0, 32); 34 } else { 35 $feedimport_where .= 'IF(cnt_prio=0, 1, '.now().'-cnt_sort>cnt_prio) AND '; 36 } 37 38 $feedimport_where .= 'MD5(CONCAT(cnt_id,cnt_text))='._dbEscape($feedimport_source); 39 40 41 unset($_getVar['feedimport']); 42 43 $feedimport_result = _dbGet('phpwcms_content', 'cnt_id,cnt_name,cnt_text,cnt_object', $feedimport_where); 44 45 if(isset($feedimport_result[0]['cnt_id'])) { 46 47 $feedimport_result = $feedimport_result[0]; 48 49 $feedimport_result['cnt_object'] = @unserialize($feedimport_result['cnt_object']); 50 51 } 52 53 if(isset($feedimport_result['cnt_object']['structure_level_id'])) { 54 55 // retrieve Feed now 56 // Load SimplePie 57 require_once (PHPWCMS_ROOT.'/include/inc_ext/SimplePie/simplepie.inc.php'); 58 59 $rss_obj = new SimplePie(); 60 61 // Feed URL 62 $rss_obj->set_feed_url( $feedimport_result['cnt_text'] ); 63 64 // Output Encoding Charset 65 $rss_obj->set_output_encoding( PHPWCMS_CHARSET ); 66 67 // Disable Feed cache 68 $rss_obj->enable_cache( false ); 69 70 // Remove surrounding DIV 71 $rss_obj->remove_div( true ); 72 73 74 // Init Feed 75 $rss_obj->init(); 76 77 if( $rss_obj->data ) { 78 79 $feedimport_result['status'] = array( 80 'Feed Importer Status - ' . date('Y-m-d, H:i:s') . LF . '===========================================', 81 $feedimport_result['cnt_name'] . LF . $feedimport_result['cnt_text'] . LF 82 ); 83 84 // need some additional functions 85 include_once (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php'); 86 87 foreach($rss_obj->get_items() as $rssvalue) { 88 89 $article_unique_hash = md5( $feedimport_result['cnt_text'] . $rssvalue->get_title() . $rssvalue->get_date('U') ); 90 91 // check against crossreference table 92 $sql = 'SELECT * FROM '.DB_PREPEND.'phpwcms_crossreference c '; 93 $sql .= 'LEFT JOIN '.DB_PREPEND.'phpwcms_article a '; 94 $sql .= 'ON c.cref_rid=a.article_id '; 95 $sql .= "WHERE c.cref_str="._dbEscape('feedimport_'.$article_unique_hash).' AND '; 96 $sql .= 'a.article_deleted=0 LIMIT 1'; 97 98 if(_dbQuery($sql, 'COUNT') > 0) { 99 continue; 100 } 101 102 103 $article_title = html_entity_decode($rssvalue->get_title(), ENT_COMPAT, PHPWCMS_CHARSET); 104 $article_alias = proof_alias(0, $article_title, 'ARTICLE'); 105 $article_begin = $rssvalue->get_date('U'); 106 $article_end = now()+(3600*24*365*10); 107 $article_summary = $rssvalue->get_description(); 108 $article_content = $rssvalue->get_content(); 109 $article_description = preg_replace('/\s+/', ' ', html_entity_decode(strip_tags($article_summary), ENT_COMPAT, PHPWCMS_CHARSET)); 110 list($article_description) = explode("\n", wordwrap($article_description, 250), 2); 111 list($article_description) = explode("-- ", $article_description, 2); 112 $article_description = preg_replace('/(.*?\.).+?$/', '$1', $article_description); 113 $article_author = $rssvalue->get_author(); 114 if($article_author) { 115 $article_author = html_entity_decode($article_author->get_name()); 116 } else { 117 $article_author = $feedimport_result['cnt_object']['author_name']; 118 } 119 120 if($feedimport_result['cnt_object']['source_link_add'] && $rssvalue->get_permalink()) { 121 $article_content .= '<p><a href="'.$rssvalue->get_permalink().'" class="feed-permalink">' . (empty($feedimport_result['cnt_object']['source_link_text']) ? '@@Source@@' : $feedimport_result['cnt_object']['source_link_text']) . '</a></p>'; 122 } 123 124 // define article data 125 $data = array( 126 127 'article_created' => now(), 128 "article_cid" => $feedimport_result['cnt_object']['structure_level_id'], 129 "article_uid" => $feedimport_result['cnt_object']['author_id'], 130 "article_title" => $article_title, 131 "article_alias" => $article_alias, 132 "article_keyword" => '', 133 "article_public" => 1, 134 "article_aktiv" => $feedimport_result['cnt_object']['activate_after_import'], 135 "article_begin" => date('Y-m-d H:i:s', $article_begin), 136 "article_end" => date('Y-m-d 23:59:59', $article_end), 137 "article_subtitle" => '', 138 "article_summary" => $article_content, 139 "article_redirect" => '', 140 "article_sort" => $article_begin, 141 "article_username" => $article_author, 142 "article_notitle" => 0, 143 "article_hidesummary" => 0, 144 "article_image" => array( 145 'tmpllist' => $feedimport_result['cnt_object']['article_template_list'], 146 'tmplfull' => $feedimport_result['cnt_object']['article_template_detail'], 147 'name' => '', 148 'id' => '', 149 'caption' => '', 150 "hash" => '', 151 'list_usesummary' => 0, 152 'list_name' => '', 153 'list_id' => 0, 154 'list_width' => '', 155 'list_height' => '', 156 'list_zoom' => 0, 157 'list_caption' => '', 158 "list_hash" => '', 159 'zoom' => 0 160 ), 161 "article_cache" => '', 162 "article_nosearch" => 0, 163 "article_nositemap" => 0, 164 "article_aliasid" => 0, 165 "article_headerdata" => 0, 166 "article_morelink" => 1, 167 "article_pagetitle" => '', 168 "article_paginate" => 0, 169 "article_priorize" => 0, 170 "article_norss" => 0, 171 "article_archive_status"=> 1, 172 "article_menutitle" => '', 173 'article_description' => $article_description, 174 'article_serialized' => '' 175 176 ); 177 178 179 $data['article_image'] = serialize($data['article_image']); 180 181 $result = _dbInsert('phpwcms_article', $data); 182 183 if(isset($result['INSERT_ID'])) { 184 185 $feedimport_result['status'][] = date('Y-m-d, H:i:s', $article_begin) . LF . $article_title . LF . $rssvalue->get_permalink() . LF . PHPWCMS_URL . 'phpwcms.php?do=articles&p=2&s=1&id='.$result['INSERT_ID']; 186 187 $data = array( 188 'cref_rid' => $result['INSERT_ID'], 189 'cref_str' => 'feedimport_'.$article_unique_hash 190 ); 191 192 _dbInsert('phpwcms_crossreference', $data); 193 194 } 195 196 } 197 198 199 // check if status email should be sent 200 if(!empty($feedimport_result['cnt_object']['import_status_email']) && is_valid_email($feedimport_result['cnt_object']['import_status_email'])) { 201 202 $feedimport_result['status'] = implode(LF.LF, $feedimport_result['status']); 203 204 sendEmail(array( 205 'recipient' => $feedimport_result['cnt_object']['import_status_email'], 206 'subject' => 'Import Status: ' . $feedimport_result['cnt_name'], 207 'isHTML' => 0, 208 'text' => $feedimport_result['status'], 209 'fromName' => 'Feed Importer' 210 )); 211 212 } 213 214 } 215 216 217 } 218 219 // we quit here 220 exit(); 221 222 } 223 224 225 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Jan 29 16:31:14 2012 | Cross-referenced by PHPXref 0.7.1 |