source: extensions/adult_content/charte_user.php @ 9557

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

activation phase without include and global var
a guest can't be logged as 16 or 18 if the admin don't want (no acces to charte.php)
a guest can't access to charte_user.php and a user can't access to charte.php

File size: 3.0 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   //include(get_language_filepath('plugin.lang.php', $adult_content->plugin_path));
15   load_language('plugin.lang', $adult_content->plugin_path);
16
17   $template->assign(
18     array(
19       'PLUGIN_NAME' => $adult_content->plugin_name
20       ));
21
22   if (isset($_GET['etat']) and $_GET['etat'] == 'not_defined' and !is_a_guest() )
23   {
24       $template->assign(
25         array(
26           'EXPLIC' => $lang['ac_not_def'],
27           'MAIN'  => $lang['ac_text_charte'],
28           'ETAT'  => $_GET['etat'],
29            )
30         );
31   }
32   elseif (isset($_GET['etat']) and $_GET['etat'] == 'defined' and !is_a_guest() )
33   {
34         $query = '
35SELECT group_id FROM '.USER_GROUP_TABLE.'
36  WHERE user_id IN (\''.$user['id'].'\')
37;';
38     $data_group = mysql_fetch_array(pwg_query($query));
39         $query = '
40SELECT name FROM '.GROUPS_TABLE.'
41  WHERE id IN (\''.$data_group['group_id'].'\')
42;';
43     $data_group_n = mysql_fetch_array(pwg_query($query));
44                 if ($data_group_n['name'] == '+18')
45                 {
46                         $statut = $lang['ac_statut'].$lang['ac_user_text_18'];
47                 }
48                 if ($data_group_n['name'] == '16-17')
49                 {
50                         $statut = $lang['ac_statut'].$lang['ac_user_text_16'];
51                 }
52                 if ($data_group_n['name'] == 'nothing')
53                 {
54                         $statut = $lang['ac_user_no'];
55                 }
56         
57     $main = '<p>'.$statut.'</p>'
58                .'<p><a href="javascript:void(0)" OnClick="history.back()" >'.$lang['ac_retour_c'].'</a></p>';
59       $template->assign(
60         array(
61           'EXPLIC' => $lang['ac_def'],
62           'MAIN'  => $main,
63           'ETAT'  => $_GET['etat'],
64            )
65         );
66   }
67   else
68   {
69                redirect(make_index_url());
70   }
71
72   $template->set_filename('charte', $adult_content->plugin_path.'include/charte_user.tpl');
73
74   $template->parse('charte');
75   include(PHPWG_ROOT_PATH.'include/page_tail.php');
76
77}//fin if !isset( $_POST['groupe'] )
78elseif ( $_POST['groupe'] == '+18' or $_POST['groupe'] == '16-17' or $_POST['groupe'] == 'nothing')
79{
80
81   ////////////placer dans group////////////
82      $query = '
83SELECT id FROM '.GROUPS_TABLE.'
84  WHERE name IN (\''. $_POST['groupe'].'\')
85;';
86      $data_group = mysql_fetch_array(pwg_query($query));
87         
88      if ($_POST['etat'] == 'not_defined')
89          {
90      pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.$user['id'].'\', \''.$data_group['id'].'\' )' );
91          }
92      elseif ($_POST['etat'] == 'defined')
93          {
94      pwg_query('UPDATE '.USER_GROUP_TABLE.' SET group_id=\''.$data_group['id'].'\' WHERE user_id IN (\''.$user['id'].'\')' );
95          }
96          $query = '
97DELETE FROM '.USER_CACHE_TABLE.'
98  WHERE user_id = '.$user['id'];
99      pwg_query($query);
100          log_user( $user['id'], false);
101      redirect(make_index_url());
102}
103else
104{
105die('Hacking attempt!');
106}
107?>
Note: See TracBrowser for help on using the repository browser.