2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
15 define('AT_INCLUDE_PATH', '../../../include/');
\r
16 require(AT_INCLUDE_PATH . 'vitals.inc.php');
\r
18 admin_authenticate(AT_ADMIN_PRIV_RSS);
\r
20 $feed_id = intval($_GET['fid']);
\r
21 $title_file = AT_CONTENT_DIR.'feeds/'.$feed_id.'_rss_title.cache';
\r
23 if (isset($_GET['submit'])) {
\r
24 $missing_fields = array();
\r
25 //check both fields are not empty
\r
26 if (trim($_REQUEST['title']) == '') {
\r
27 $missing_fields[] = _AT('title');
\r
32 if (trim($_REQUEST['url']) == '') {
\r
33 $missing_fields[] = _AT('url');
\r
35 if ($missing_fields) {
\r
36 $missing_fields = implode(', ', $missing_fields);
\r
37 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
\r
40 if (!$msg->containsErrors()) {
\r
41 $_GET['url'] = $addslashes($_GET['url']);
\r
43 $sql = "REPLACE INTO ".TABLE_PREFIX."feeds VALUES(".$feed_id.", '".$_GET['url']."')";
\r
44 $result = mysql_query($sql, $db);
\r
47 if ($f = @fopen($title_file, 'w')) {
\r
48 fwrite($f, $_GET['title'], strlen($_GET['title']));
\r
52 //delete old cache file
\r
53 @unlink(AT_CONTENT_DIR.'/feeds/'.$feed_id.'_rss.cache');
\r
55 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
56 header('Location: index.php');
\r
60 } else if (isset($_GET['cancel'])) {
\r
61 $msg->addFeedback('CANCELLED');
\r
62 header("Location:index.php");
\r
66 if ($feed_id != '') {
\r
68 $sql = "SELECT * FROM ".TABLE_PREFIX."feeds WHERE feed_id=".$feed_id;
\r
69 $result = mysql_query($sql, $db);
\r
70 $row = mysql_fetch_assoc($result);
\r
72 if (file_exists($title_file)) {
\r
73 $_GET['title'] = file_get_contents($title_file);
\r
75 $_GET['url'] = $row['url'];
\r
78 $onload = 'document.form.title.focus();';
\r
80 require (AT_INCLUDE_PATH.'header.inc.php');
\r
81 $savant->assign('feed_id', $feed_id);
\r
82 $savant->display('admin/system_preferences/edit_feed.tmpl.php');
\r
83 require (AT_INCLUDE_PATH.'footer.inc.php'); ?>