source: extensions/adult_content/charte_user.php @ 9564

Last change on this file since 9564 was 9564, checked in by flop25, 13 years ago

bug:1901
lots of bugs will be solved now, because the plugin were not able to manage users with multiple groups (the groups with an id inferior than the groups of Adultcontent caused bugs).

File size: 2.8 KB
Line 
1<?php
2define('PHPWG_ROOT_PATH','../../');
3include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
4$adult_content = get_plugin_data('adult_content');
5if ( is_a_guest() )
6{
7        redirect(make_index_url());
8}
9if (!isset( $_POST['groupe'] ))
10{
11   $title = 'Adult content';
12   $page['body_id'] = 'adult_content_page';
13   include(PHPWG_ROOT_PATH.'include/page_header.php');
14   load_language('plugin.lang', $adult_content->plugin_path);
15
16   $template->assign(
17     array(
18       'PLUGIN_NAME' => $adult_content->plugin_name
19       ));
20////////////lié à quoi/////     
21                        $adult_content->fill_idgroups_user();
22                        $adult_content->fill_idgroups_ad_c();   
23
24        if (!is_a_guest() and !$adult_content->is_in_ad_c_group())
25        {
26                 $template->assign(
27                         array(
28                                 'EXPLIC' => $lang['ac_not_def'],
29                                 'MAIN'  => $lang['ac_text_charte'],
30                                        )
31                         );
32        }
33        elseif (!is_a_guest()  and $adult_content->is_in_ad_c_group() )
34        {
35                $link=$adult_content->is_in_ad_c_group();
36                if ($link == $adult_content->idgroups_ad_c[0])
37                {
38                         $statut = $lang['ac_statut'].$lang['ac_user_text_18'];
39                }
40                if ($link ==  $adult_content->idgroups_ad_c[1])
41                {
42                         $statut = $lang['ac_statut'].$lang['ac_user_text_16'];
43                }
44                if ($link ==  $adult_content->idgroups_ad_c[2])
45                {
46                         $statut = $lang['ac_user_no'];
47                }
48         
49     $main = '<p>'.$statut.'</p>'
50                .'<p><a href="javascript:void(0)" OnClick="history.back()" >'.$lang['ac_retour_c'].'</a></p>';
51       $template->assign(
52         array(
53           'EXPLIC' => $lang['ac_def'],
54           'MAIN'  => $main,
55            )
56         );
57   }
58   else
59   {
60                redirect(make_index_url());
61   }
62
63   $template->set_filename('charte', $adult_content->plugin_path.'include/charte_user.tpl');
64
65   $template->parse('charte');
66   include(PHPWG_ROOT_PATH.'include/page_tail.php');
67
68}//fin if !isset( $_POST['groupe'] )
69elseif ( $_POST['groupe'] == '+18' or $_POST['groupe'] == '16-17' or $_POST['groupe'] == 'nothing')
70{
71////////////anciennement lié à quoi/////       
72                        $adult_content->fill_idgroups_user();
73                        $adult_content->fill_idgroups_ad_c();
74   ////////////placer dans group////////////
75      $query = '
76SELECT id FROM '.GROUPS_TABLE.'
77  WHERE name IN (\''. $_POST['groupe'].'\')
78;';
79      $data_group = mysql_fetch_array(pwg_query($query));
80         
81      if (!$adult_content->is_in_ad_c_group())
82          {
83      pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.$user['id'].'\', \''.$data_group['id'].'\' )' );
84          }
85      else
86          {
87      pwg_query('UPDATE '.USER_GROUP_TABLE.' SET group_id=\''.$data_group['id'].'\' WHERE user_id IN (\''.$user['id'].'\') AND group_id IN (\''.$adult_content->is_in_ad_c_group().'\')' );
88          }
89          $query = '
90DELETE FROM '.USER_CACHE_TABLE.'
91  WHERE user_id = '.$user['id'];
92      pwg_query($query);
93          log_user( $user['id'], false);
94      redirect(make_index_url());
95}
96else
97{
98die('Hacking attempt!');
99}
100?>
Note: See TracBrowser for help on using the repository browser.