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 if (isset($_POST['cancel'])) {
\r
21 $msg->addFeedback('CANCELLED');
\r
22 header("Location: index_admin.php");
\r
24 } else if (isset($_POST['submit'])) {
\r
25 $missing_fields = array();
\r
27 if (trim($_POST['title']) == '') {
\r
28 $missing_fields[] = _AT('title');
\r
30 if (trim($_POST['url']) == '') {
\r
31 $missing_fields[] = _AT('url');
\r
33 if ($missing_fields) {
\r
34 $missing_fields = implode(', ', $missing_fields);
\r
35 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
\r
38 if (!$msg->containsErrors()) {
\r
39 $output = make_cache_file(0);
\r
40 if (!isset($output) || empty($output)) {
\r
41 $msg->addError('FEED_NO_CONTENT');
\r
45 if ($msg->containsErrors()) {
\r
46 unset($_POST['confirm']);
\r
49 } else if (isset($_POST['submit_no'])) {
\r
50 $msg->addFeedback('CANCELLED');
\r
52 } else if (isset($_POST['submit_yes'])) {
\r
53 $_POST['url'] = $addslashes($_POST['url']);
\r
55 $sql = "INSERT INTO ".TABLE_PREFIX."feeds VALUES (NULL, '".$_POST['url']."')";
\r
56 $result = mysql_query($sql, $db);
\r
58 $feed_id = mysql_insert_id($db);
\r
61 copy('load_file.php', AT_CONTENT_DIR.'feeds/'.$feed_id.'_rss.inc.php');
\r
64 $title_file = AT_CONTENT_DIR.'feeds/'.$feed_id.'_rss_title.cache';
\r
65 if ($f = @fopen($title_file, 'w')) {
\r
66 fwrite ($f, $_POST['title'], strlen($_POST['title']));
\r
70 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
71 header('Location: index.php');
\r
75 $onload = 'document.form.title.focus();';
\r
76 $hidden_vars['new'] = '1';
\r
77 $hidden_vars['title'] = $_POST['title'];
\r
78 $hidden_vars['url'] = $_POST['url'];
\r
80 $msg->addConfirm('ADD_FEED', $hidden_vars);
\r
81 require (AT_INCLUDE_PATH.'header.inc.php');
\r
83 $savant->assign('msg', $msg);
\r
84 $savant->assign('output', $output);
\r
85 $savant->assign('title_file', $title_file);
\r
86 $savant->display('admin/system_preferences/add_feed.tmpl.php');
\r
87 require (AT_INCLUDE_PATH.'footer.inc.php'); ?>