root/getrss.php

Revision 297, 2.1 kB (checked in by Nafania, 2 years ago)

--

Line 
1 <?php</span>
2 <span class="code-lang">$root_path = './';
3 require ($root_path . 'include/config.php');
4
5 $userdata = session_pagestart($user_ip);
6 init_userprefs($userdata);
7 loggedinorreturn();
8
9 $sql = 'SELECT * FROM ' . CATEGORIES_TABLE . ' ORDER BY cat_parent_id, name';
10 $result = $db->sql_query($sql, 30 * 60);
11
12 $cats = array();</span>
13 <span class="code-lang">while( $row = $db->sql_fetchrow($result) ){
14     $parent_cat_id = ( $row['cat_parent_id'] ? $row['cat_parent_id'] : $row['id'] );
15     $cats[$parent_cat_id][$row['id']] = $row['name'];
16 }
17
18 if ( isset($_POST['submit']) ) {
19     $link = generate_base_url() . '/rss.php';
20
21     $login_type = request_var('login', '');
22     $feed = request_var('feed', '');
23     $cat = request_var('cat', array( 0 => 0 ) );
24     if ( $feed == 'dl' ) {
25         $query[] = 'feed=dl';
26      }
27
28     if ( sizeof($cat) != sizeof($cats) && sizeof($cat) ) {
29         $query[] = 'cat=' . implode(',', $cat);
30     }
31
32     if ( $login_type == 'passkey' ) {
33         $query[] = 'passkey=' . $userdata['torrent_pass'];
34      }
35     $queries = implode('&', $query);
36     if ( $queries ) {
37         $link .= '?' . $queries;
38      }
39      trigger_error(sprintf($lang['use_this_rss_adress'], $link, $link));
40 }
41 else {
42     $catoptions = '';
43
44     foreach ( $cats AS $cat_id => $ary ) {
45         $main_cat_name = reset($ary);
46         $selected =  (strpos($userdata['notifs'], '[cat' . $cat_id . ']') !== false ? ' checked="checked"' : '');
47         $catoptions .= '<input type="checkbox" name="cat[]" value="' . $cat_id . '"' . $selected . ' /> ' . $main_cat_name . "<br />\n";
48
49         unset($ary[$cat_id]);
50         if ( $count = sizeof($ary) ) {
51             $value = '';
52             foreach( $ary AS $key => $value ) {
53                 $selected =  (strpos($userdata['notifs'], '[cat' . $cat_id . ']') !== false ? ' checked="checked"' : '');
54                 $catoptions .= ' --> <input type="checkbox" name="cat[]" value="' . $key . '"' . $selected . ' /> ' . $value. "<br />\n";
55             }
56         }
57     }
58
59      $template->assign_vars(array(
60          'CATOPTIONS' => $catoptions,
61           'S_FORM_ACTION' => append_sid('getrss.php')
62     ));
63
64     stdhead($lang['rss']);
65     $template->set_filenames(array(
66         'body' => 'getrss.html')
67      );
68      stdfoot();
69 }
70 ?>
Note: See TracBrowser for help on using the browser.