root/faq.php

Revision 300, 4.6 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
8 //tiny function to get sysop link for faq
9 function get_sysop_link ( $type ) {</span>
10 <span class="code-keyword">    global $db, $seo, $root_path;
11
12     $sql = 'SELECT uid, name FROM ' . USERS_TABLE . ' WHERE class = ' . UC_SYSOP . ' LIMIT 1';
13     $result = $db->sql_query($sql, 31536000);
14     $row = $db->sql_fetchrow($result);
15
16     switch ( $type ) {
17         case 1:
18             return $row['uid'];
19         break;
20
21         case 2:
22             return $row['name'];
23         break;
24
25         case 3:
26             $seo->set_user_url($row['name'], $row['uid']);
27             return '<a href="' . append_sid($root_path . 'userdetails.php?id=' . $row['uid']) . '">' . $row['name'] . '</a>';
28         break;
29     }
30 }
31
32 $mode = request_var('mode', '');</span>
33 <span class="code-lang">
34 switch( $mode ) {
35     case 'anatomy':
36         $lang_file = 'lang_anatomy.php';
37      break;
38
39     case 'formats':
40          $lang_file = 'lang_formats.php';
41      break;
42
43     case 'videoformats':
44          $lang_file = 'lang_videoformats.php';
45      break;
46
47      case 'tags':
48          $lang_file = 'lang_faq_bbcode.php';
49
50          function parse_faq_lang ( &$faq ) {
51              global $root_path, $lang;
52              static $bb_code;
53
54              require ($root_path . 'include/bbcode/config/tags.php');
55              require ($root_path . 'include/bbcode/bbcode.lib.php');
56
57              $faq_tags = array();
58              $tags = array_keys($tags);
59
60             if ( !isset($bb_code) ) {
61                 $bb_code = new bbcode();
62             }
63
64              for($i = 0, $count = sizeof($faq); $i < $count; $i++) {
65                  if ( $faq[$i][0] != '--' ) {
66                      list($name, $tag, $descr, $explain) = $faq[$i];
67
68                     $parsed = $explain;
69
70                         $bb_code->parse($parsed);
71                         $parsed = $bb_code->get_html();
72
73                      $faq_text = $lang['tag'] . ': [' . $tag . ']<br />';
74                      $faq_text .= $lang['description'] . ': ' . $descr . '<br />';
75                      $faq_text .= '<div class="codetitle"><b>' . $lang['example'] . ':</b></div><div class="codecontent">' . $explain . '</div>';
76                      $faq_text .= '<div class="codetitle"><b>' . $lang['result'] . ':</b></div><div class="codecontent">' . $parsed . '</div>';
77
78                      $faq[$i] = array(
79                         0 => '[' . $tag . '] ' . $name,
80                         1 => $faq_text,
81                      );
82
83                      $faq_tags[] = $tag;
84                 }
85              }
86
87              $tags_diff = array_diff($tags, $faq_tags);
88
89              if ( sizeof($tags_diff) ) {
90                  $faq[$i] = array(
91                      0 => $lang['other_tags'],
92                      1 => implode(', ', $tags_diff),
93                  );
94              }
95          }
96      break;
97
98      default:
99          $lang_file = 'lang_faq.php';
100      break;
101 }
102
103 $user_limit_ary_torrents = unserialize($config['user_limit_ary_torrents']);</span>
104 <span class="code-lang">require_once ($root_path . 'languages/lang_' . ( $userdata['session_logged_in'] ? $userdata['language'] : $config['default_lang']) . '/' . $lang_file);
105
106 if ( function_exists('parse_faq_lang') ) {
107     parse_faq_lang($faq);
108 }
109
110 $j = 0;
111 $counter = 0;
112 $counter_2 = 0;
113 $faq_block = array();
114 $faq_block_titles = array();</span>
115 <span class="code-lang">
116 for($i = 0, $count = sizeof($faq); $i < $count; $i++)
117 {
118     if ( !empty($faq[$i][0]) ) {
119          if( $faq[$i][0] != '--' ) {
120               $faq_block[$j][$counter]['id'] = $counter_2;
121             $faq_block[$j][$counter]['question'] = $faq[$i][0];
122               $faq_block[$j][$counter]['answer'] = $faq[$i][1];
123
124               $counter++;
125               $counter_2++;
126           }
127          else {
128             $j = ( $counter != 0 ) ? $j + 1 : 0;
129
130               $faq_block_titles[$j] = $faq[$i][1];
131
132               $counter = 0;
133          }
134      }
135 }
136
137 for($i = 0, $count = sizeof($faq_block); $i < $count; $i++) {
138     if( sizeof($faq_block[$i]) ) {
139         $template->assign_block_vars('faq_block', array(
140               'BLOCK_TITLE' => $faq_block_titles[$i]
141         ));
142
143         for($j = 0; $j < count($faq_block[$i]); $j++) {
144             $template->assign_block_vars('faq_block.faq_row', array(
145                 'ID' =>  $faq_block[$i][$j]['id'],
146                 'QUESTION' => $faq_block[$i][$j]['question']
147             ));
148           }
149     }
150 }
151
152
153 for($i = 0, $count = sizeof($faq_block); $i < $count; $i++) {
154     if( sizeof($faq_block[$i]) ) {
155         $template->assign_block_vars('answers_block', array(
156             'BLOCK_TITLE' => $faq_block_titles[$i]
157         ));
158
159         for( $j = 0; $j < count($faq_block[$i]); $j++ ) {
160             $template->assign_block_vars('answers_block.answers_row', array(
161                 'ID' =>  $faq_block[$i][$j]['id'],
162                     'QUESTION' => $faq_block[$i][$j]['question'],
163                     'ANSWER' => $faq_block[$i][$j]['answer']
164             ));
165           }
166     }
167 }
168
169 $template->assign_vars( array(</span>
170 <span class="code-lang">    'L_LANG_FAQ_COPYRIGHT' => $lang['lang_faq_copyright'],
171 ));
172
173 stdhead($lang['faq']);
174 $template->set_filenames(array(</span>
175 <span class="code-lang">        'body' => 'faq.html'
176 ));
177 stdfoot();
178 ?>
Note: See TracBrowser for help on using the browser.