/** * * Checks to see if RDF file needs updating and updates it if so. * Checks to see if we need to update the RDF as a result * of an article with a future publish date reaching it's * publish time and if so updates the RDF file. * * NOTE: When called without parameters, this will only check for new entries to * include in the feeds. Pass the $updated_XXX parameters when the content * of an existing entry has changed. * * @param string $updated_type (optional) feed type to update * @param string $updated_topic (optional) feed topic to update * @param string $updated_id (optional) feed id to update * * @see file lib-syndication.php * */ function COM_rdfUpToDateCheck($updated_type = '', $updated_topic = '', $updated_id = '') { global $_CONF, $_TABLES; if ($_CONF['backend'] > 0) { if (!empty($updated_type) && $updated_type != 'article') { // when a plugin's feed is to be updated, skip Geeklog's own feeds $sql = "SELECT fid,type,topic,limits,update_info FROM {$_TABLES['syndication']} WHERE (is_enabled = 1) AND (type <> 'article')"; } else { $sql = "SELECT fid,type,topic,limits,update_info FROM {$_TABLES['syndication']} WHERE is_enabled = 1"; } $result = DB_query($sql); $num = DB_numRows($result); for ($i = 0; $i < $num; $i++) { $A = DB_fetchArray($result); $is_current = true; if ($A['type'] == 'article') { $is_current = SYND_feedUpdateCheck($A['topic'], $A['update_info'], $A['limits'], $updated_topic, $updated_id); } else { $is_current = PLG_feedUpdateCheck($A['type'], $A['fid'], $A['topic'], $A['update_info'], $A['limits'], $updated_type, $updated_topic, $updated_id); } if (!$is_current) { SYND_updateFeed($A['fid']); } } } }
/** * Save feed. * * @param array $A * @return string HTML redirect on success or feed editor + error message * */ function savefeed($A) { global $_CONF, $_TABLES, $LANG33; foreach ($A as $name => $value) { $A[$name] = COM_stripslashes($value); } if (isset($A['is_enabled']) && $A['is_enabled'] == 'on') { $A['is_enabled'] = 1; } else { $A['is_enabled'] = 0; } // Make sure correct format returned and correct file extenstion $A['filename'] = COM_sanitizeFilename($A['filename'], true); $file_parts = pathinfo($A['filename']); $A['filename'] = ''; // Clear out filename. If it doesn't get recreated then we know there is an error if (!empty($file_parts['filename'])) { $formats = find_feedFormats(); foreach ($formats as $f) { if ($A['format'] == $f['name'] . '-' . $f['version']) { switch ($f['name']) { case 'Atom': if (!in_array(@$file_parts['extension'], array('atm', 'xml'))) { $file_parts['extension'] = 'xml'; } $A['filename'] = $file_parts['filename'] . '.' . $file_parts['extension']; break; case 'RSS': if (!in_array(@$file_parts['extension'], array('rss', 'xml'))) { $file_parts['extension'] = 'rss'; } $A['filename'] = $file_parts['filename'] . '.' . $file_parts['extension']; break; case 'RDF': $A['filename'] = $file_parts['filename'] . '.rdf'; break; } } } } if (empty($A['title']) || empty($A['description']) || empty($A['filename'])) { $retval = COM_showMessageText($LANG33[39], $LANG33[38]) . editfeed($A['fid'], $A['type']); $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG33[38])); return $retval; } $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['syndication']} WHERE filename = '{$A['filename']}' AND (fid <> '{$A['fid']}')"); $C = DB_fetchArray($result); if ($C['count'] > 0) { $retval = COM_showMessageText($LANG33[51], $LANG33[52]) . editfeed($A['fid'], $A['type']); $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG33[52])); return $retval; } if ($A['limits'] <= 0) { $retval = COM_showMessageText($LANG33[40], $LANG33[38]) . editfeed($A['fid'], $A['type']); $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG33[38])); return $retval; } if ($A['limits_in'] == 1) { $A['limits'] .= 'h'; } // we can compensate if these are missing ... if (!empty($A['charset'])) { $A['charset'] = preg_replace('/[^0-9a-zA-Z_\\-]/', '', $A['charset']); } if (empty($A['charset'])) { $A['charset'] = $_CONF['default_charset']; if (empty($A['charset'])) { $A['charset'] = 'UTF-8'; } } if (!empty($A['language'])) { $A['language'] = preg_replace('/[^0-9a-zA-Z_\\.\\-]/', '', $A['language']); } if (empty($A['language'])) { $A['language'] = $_CONF['rdf_language']; if (empty($A['language'])) { $A['language'] = $_CONF['locale']; } } if (!empty($A['content_length'])) { $A['content_length'] = intval($A['content_length'], 10); } if (empty($A['content_length']) || $A['content_length'] < 0) { $A['content_length'] = 0; } foreach ($A as $name => $value) { $A[$name] = DB_escapeString($value); } DB_save($_TABLES['syndication'], 'fid,type,topic,header_tid,format,limits,content_length,title,description,feedlogo,filename,charset,language,is_enabled,updated,update_info', "{$A['fid']},'{$A['type']}','{$A['topic']}','{$A['header_tid']}','{$A['format']}','{$A['limits']}',{$A['content_length']},'{$A['title']}','{$A['description']}','{$A['feedlogo']}','{$A['filename']}','{$A['charset']}','{$A['language']}',{$A['is_enabled']},'0000-00-00 00:00:00',NULL"); if ($A['fid'] == 0) { $A['fid'] = DB_insertId(); } if ($A['is_enabled'] == 1) { SYND_updateFeed($A['fid']); } else { deleteFeedFile($A['filename']); } return COM_refresh($_CONF['site_admin_url'] . '/syndication.php?msg=58'); }
/** * Save feed. * * @param array $A * @return string HTML redirect on success or feed editor + error message * */ function FEED_save($A) { global $_CONF, $_TABLES, $LANG33; foreach ($A as $name => $value) { $A[$name] = $value; } if ($A['is_enabled'] == 'on') { $A['is_enabled'] = 1; } else { $A['is_enabled'] = 0; } if (empty($A['title']) || empty($A['description']) || empty($A['filename'])) { $retval = COM_siteHeader('menu', $LANG33[38]) . COM_showMessageText($LANG33[39], $LANG33[38], true) . FEED_edit($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['syndication']} WHERE filename = '{$A['filename']}' AND (fid <> '{$A['fid']}')"); $C = DB_fetchArray($result); if ($C['count'] > 0) { $retval = COM_siteHeader('menu', $LANG33[52]) . COM_showMessageText($LANG33[51], $LANG33[52], true) . FEED_edit($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } if ($A['limits'] <= 0) { $retval = COM_siteHeader('menu', $LANG33[38]) . COM_showMessageText($LANG33[40], $LANG33[38], true) . FEED_edit($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } if ($A['limits_in'] == 1) { $A['limits'] .= 'h'; } // we can compensate if these are missing ... if (empty($A['charset'])) { $A['charset'] = $_CONF['default_charset']; if (empty($A['charset'])) { $A['charset'] = 'UTF-8'; } } if (empty($A['language'])) { $A['language'] = $_CONF['rdf_language']; if (empty($A['language'])) { $A['language'] = $_CONF['locale']; } } if (empty($A['content_length']) || $A['content_length'] < 0) { $A['content_length'] = 0; } foreach ($A as $name => $value) { $A[$name] = DB_escapeString($value); } DB_save($_TABLES['syndication'], 'fid,type,topic,header_tid,format,limits,content_length,title,description,feedlogo,filename,charset,language,is_enabled,updated,update_info', "{$A['fid']},'{$A['type']}','{$A['topic']}','{$A['header_tid']}','{$A['format']}','{$A['limits']}',{$A['content_length']},'{$A['title']}','{$A['description']}','{$A['feedlogo']}','{$A['filename']}','{$A['charset']}','{$A['language']}',{$A['is_enabled']},'1000-01-01 00:00:00',NULL"); if ($A['fid'] == 0) { $A['fid'] = DB_insertId(); } SYND_updateFeed($A['fid']); CACHE_remove_instance('story'); COM_setMessage(58); return COM_refresh($_CONF['site_admin_url'] . '/syndication.php'); }
/** * Save feed. * * @param array $A * @return string HTML redirect on success or feed editor + error message * */ function savefeed($A) { global $_CONF, $_TABLES, $LANG33; foreach ($A as $name => $value) { $A[$name] = COM_stripslashes($value); } if (isset($A['is_enabled']) && $A['is_enabled'] == 'on') { $A['is_enabled'] = 1; } else { $A['is_enabled'] = 0; } if (empty($A['title']) || empty($A['description']) || empty($A['filename'])) { $retval = COM_siteHeader('menu', $LANG33[38]) . COM_startBlock($LANG33[38], '', COM_getBlockTemplate('_msg_block', 'header')) . $LANG33[39] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')) . editfeed($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['syndication']} WHERE filename = '{$A['filename']}' AND (fid <> '{$A['fid']}')"); $C = DB_fetchArray($result); if ($C['count'] > 0) { $retval = COM_siteHeader('menu', $LANG33[52]) . COM_startBlock($LANG33[52], '', COM_getBlockTemplate('_msg_block', 'header')) . $LANG33[51] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')) . editfeed($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } if ($A['limits'] <= 0) { $retval = COM_siteHeader('menu', $LANG33[38]) . COM_startBlock($LANG33[38], '', COM_getBlockTemplate('_msg_block', 'header')) . $LANG33[40] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')) . editfeed($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } if ($A['limits_in'] == 1) { $A['limits'] .= 'h'; } // we can compensate if these are missing ... if (empty($A['charset'])) { $A['charset'] = $_CONF['default_charset']; if (empty($A['charset'])) { $A['charset'] = 'UTF-8'; } } if (empty($A['language'])) { $A['language'] = $_CONF['rdf_language']; if (empty($A['language'])) { $A['language'] = $_CONF['locale']; } } if (empty($A['content_length']) || $A['content_length'] < 0) { $A['content_length'] = 0; } foreach ($A as $name => $value) { $A[$name] = addslashes($value); } DB_save($_TABLES['syndication'], 'fid,type,topic,header_tid,format,limits,content_length,title,description,feedlogo,filename,charset,language,is_enabled,updated,update_info', "{$A['fid']},'{$A['type']}','{$A['topic']}','{$A['header_tid']}','{$A['format']}','{$A['limits']}',{$A['content_length']},'{$A['title']}','{$A['description']}','{$A['feedlogo']}','{$A['filename']}','{$A['charset']}','{$A['language']}',{$A['is_enabled']},'0000-00-00 00:00:00',NULL"); if ($A['fid'] == 0) { $A['fid'] = DB_insertId(); } if ($A['is_enabled'] == 1) { SYND_updateFeed($A['fid']); } else { deleteFeedFile($A['filename']); } return COM_refresh($_CONF['site_admin_url'] . '/syndication.php?msg=58'); }