1 | <?php |
---|
2 | |
---|
3 | |
---|
4 | class Adultcontent |
---|
5 | { |
---|
6 | var $plugin_name, $plugin_path; |
---|
7 | |
---|
8 | function Adultcontent($plugin_name, $plugin_path) |
---|
9 | { |
---|
10 | // Args |
---|
11 | $this->plugin_name = $plugin_name; |
---|
12 | $this->plugin_path = $plugin_path; |
---|
13 | // handler |
---|
14 | // $this->initialize_event_handler(); |
---|
15 | } |
---|
16 | |
---|
17 | function get_link_icon($main_link, $action) |
---|
18 | { |
---|
19 | $link_url = add_url_params($main_link, array('ad' => $action)); |
---|
20 | return $link_url; |
---|
21 | } |
---|
22 | |
---|
23 | function loading_lang() |
---|
24 | { |
---|
25 | global $lang; |
---|
26 | load_language('plugin.lang', $this->plugin_path); |
---|
27 | } |
---|
28 | function var_template() |
---|
29 | { |
---|
30 | global $user; |
---|
31 | if ($user['template'] == 'flop_pure_design') |
---|
32 | { |
---|
33 | $r = 'var_fpd.inc.php'; |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | $r = 'var.inc.php'; |
---|
38 | } |
---|
39 | return $r; |
---|
40 | } |
---|
41 | |
---|
42 | function register_ac_menubar_blocks($menu_ref_arr) { |
---|
43 | $menu = & $menu_ref_arr[0]; |
---|
44 | if ($menu->get_id() != 'menubar') |
---|
45 | return; |
---|
46 | $menu->register_block(new RegisteredBlock('mbAdultContent', 'Adult Content', 'AC')); |
---|
47 | } |
---|
48 | |
---|
49 | function placer_identification($menu_ref_arr) |
---|
50 | { |
---|
51 | ///////////////////////[début du plug]//////////////////// |
---|
52 | $this->loading_lang(); |
---|
53 | global $user, $conf, $page; |
---|
54 | global $template; |
---|
55 | |
---|
56 | $menu = & $menu_ref_arr[0]; |
---|
57 | |
---|
58 | $template->assign( |
---|
59 | array( |
---|
60 | 'AC_NAME' => AC_NAME |
---|
61 | )); |
---|
62 | |
---|
63 | |
---|
64 | //include($this->var_template()); |
---|
65 | if (is_a_guest()) |
---|
66 | { |
---|
67 | |
---|
68 | ///////////////////////[gestion fermer/ouvert]//////////////////// |
---|
69 | if ( !isset( $_GET['ad'] ) ) |
---|
70 | { |
---|
71 | if ( !isset( $_COOKIE['pwg_adult_content'] ) or $_COOKIE['pwg_adult_content'] == 'open' ) |
---|
72 | { |
---|
73 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'closed') )); |
---|
74 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
75 | $block->set_title(l10n('ac_title_menu')); |
---|
76 | $block->template = $this->plugin_path.'template/'.$user['template'].'/opened.tpl'; |
---|
77 | } |
---|
78 | } |
---|
79 | elseif ( $_COOKIE['pwg_adult_content'] == 'closed' ) |
---|
80 | { |
---|
81 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'open') )); |
---|
82 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
83 | $block->set_title(l10n('ac_title_fermer')); |
---|
84 | $block->template = $this->plugin_path.'template/'.$user['template'].'/closed.tpl'; |
---|
85 | } |
---|
86 | |
---|
87 | } |
---|
88 | } |
---|
89 | elseif ( $_GET['ad'] == 'closed' ) |
---|
90 | { |
---|
91 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'open') )); |
---|
92 | setcookie( 'pwg_adult_content', 'closed', time()+60*60*24*30, cookie_path() ); |
---|
93 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
94 | $block->set_title(l10n('ac_title_fermer')); |
---|
95 | $block->template = $this->plugin_path.'template/'.$user['template'].'/closed.tpl'; |
---|
96 | } |
---|
97 | } |
---|
98 | elseif ( $_GET['ad'] == 'open' ) |
---|
99 | { |
---|
100 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'closed') )); |
---|
101 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
102 | $block->set_title(l10n('ac_title_menu')); |
---|
103 | $block->template = $this->plugin_path.'template/'.$user['template'].'/opened.tpl'; |
---|
104 | } |
---|
105 | |
---|
106 | setcookie( 'pwg_adult_content', 'open', time()+60*60*24*30, cookie_path() ); |
---|
107 | } |
---|
108 | ///////////////////////[FIN fermer/ouvert]//////////////////// |
---|
109 | }//fin if guest |
---|
110 | elseif ($user['username'] == '18') |
---|
111 | { |
---|
112 | $menu->hide_block('mbIdentification'); |
---|
113 | $template->assign( |
---|
114 | array( |
---|
115 | 'AC_MSG' => l10n('ac_user_text_18') |
---|
116 | )); |
---|
117 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
118 | $block->set_title(l10n('ac_title_menu')); |
---|
119 | $block->template = $this->plugin_path.'template/'.$user['template'].'/msg.tpl'; |
---|
120 | } |
---|
121 | |
---|
122 | $_SESSION['age']="18"; |
---|
123 | setcookie( 'age', '18', time()+60*60*24*30, cookie_path() ); |
---|
124 | |
---|
125 | }//fin if 18 ans |
---|
126 | elseif ($user['username'] == '16') |
---|
127 | { |
---|
128 | $menu->hide_block('mbIdentification'); |
---|
129 | $template->assign( |
---|
130 | array( |
---|
131 | 'AC_MSG' => l10n('ac_user_text_16') |
---|
132 | )); |
---|
133 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
134 | $block->set_title(l10n('ac_title_menu')); |
---|
135 | $block->template = $this->plugin_path.'template/'.$user['template'].'/msg.tpl'; |
---|
136 | } |
---|
137 | |
---|
138 | }//fin if 16-17 ans |
---|
139 | elseif (!is_admin()) |
---|
140 | { |
---|
141 | |
---|
142 | ////////////lié à quoi///// |
---|
143 | $query = ' |
---|
144 | SELECT id FROM '.GROUPS_TABLE.' |
---|
145 | WHERE name IN (\'+18\') |
---|
146 | ;'; |
---|
147 | $data_18 = mysql_fetch_array(pwg_query($query)); |
---|
148 | $query = ' |
---|
149 | SELECT id FROM '.GROUPS_TABLE.' |
---|
150 | WHERE name IN (\'16-17\') |
---|
151 | ;'; |
---|
152 | $data_16 = mysql_fetch_array(pwg_query($query)); |
---|
153 | $query = ' |
---|
154 | SELECT id FROM '.GROUPS_TABLE.' |
---|
155 | WHERE name IN (\'nothing\') |
---|
156 | ;'; |
---|
157 | $data_no = mysql_fetch_array(pwg_query($query)); |
---|
158 | $n_query = ' |
---|
159 | SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.' |
---|
160 | WHERE group_id IN (\''.$data_18['id'].'\',\''.$data_16['id'].'\',\''.$data_no['id'].'\') AND user_id IN (\''.$user['id'].'\') |
---|
161 | ;'; |
---|
162 | $data_user = mysql_fetch_array(pwg_query($n_query)); |
---|
163 | $is_grouped = $data_user['result']; |
---|
164 | |
---|
165 | if ( $is_grouped == 0 ) |
---|
166 | { |
---|
167 | $template->assign( |
---|
168 | array( |
---|
169 | 'AC_ETAT' => 'not_defined', |
---|
170 | 'AC_MSG' => l10n('ac_charte_user_not') |
---|
171 | )); |
---|
172 | $menu = & $menu_ref_arr[0]; |
---|
173 | $block = $menu->get_block( 'mbAdultContent' ); |
---|
174 | $block->set_title(l10n('ac_title_choose')); |
---|
175 | $block->template = $this->plugin_path.'template/'.$user['template'].'/choose.tpl'; |
---|
176 | |
---|
177 | } |
---|
178 | else |
---|
179 | { |
---|
180 | $query = ' |
---|
181 | SELECT group_id FROM '.USER_GROUP_TABLE.' |
---|
182 | WHERE user_id IN (\''.$user['id'].'\') |
---|
183 | ;'; |
---|
184 | $data_group = mysql_fetch_array(pwg_query($query)); |
---|
185 | $query = ' |
---|
186 | SELECT name FROM '.GROUPS_TABLE.' |
---|
187 | WHERE id IN (\''.$data_group['group_id'].'\') |
---|
188 | ;'; |
---|
189 | $data_group_n = mysql_fetch_array(pwg_query($query)); |
---|
190 | if ($data_group_n['name'] == '+18') |
---|
191 | { |
---|
192 | $statut = l10n('ac_user_text_18'); |
---|
193 | } |
---|
194 | if ($data_group_n['name'] == '16-17') |
---|
195 | { |
---|
196 | $statut = l10n('ac_user_text_16'); |
---|
197 | } |
---|
198 | if ($data_group_n['name'] == 'nothing') |
---|
199 | { |
---|
200 | $statut = l10n('ac_user_no_s'); |
---|
201 | } |
---|
202 | $template->assign( |
---|
203 | array( |
---|
204 | 'AC_ETAT' => 'defined', |
---|
205 | 'AC_MSG' => $statut.". ".l10n('ac_charte_user_def') |
---|
206 | )); |
---|
207 | $menu = & $menu_ref_arr[0]; |
---|
208 | $block = $menu->get_block( 'mbAdultContent' ); |
---|
209 | $block->set_title(l10n('ac_title_menu_statut')); |
---|
210 | $block->template = $this->plugin_path.'template/'.$user['template'].'/choose.tpl'; |
---|
211 | |
---|
212 | } |
---|
213 | } |
---|
214 | |
---|
215 | }//fin placer_identification |
---|
216 | function on_register() |
---|
217 | { |
---|
218 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
219 | $user_id = get_userid($_POST['login']); |
---|
220 | log_user( $user_id, false); |
---|
221 | redirect(PHPWG_ROOT_PATH.'plugins/adult_content/charte_user.php?etat=not_defined'); |
---|
222 | } |
---|
223 | }//fin class |
---|
224 | ?> |
---|