[3331] | 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 | } |
---|
[4078] | 48 | function ac_lien_menu($menu) |
---|
| 49 | { |
---|
| 50 | array_push($menu, array('NAME' => 'Adult Content', |
---|
| 51 | 'URL' => get_admin_plugin_menu_link(get_root_url().'plugins/'.$this->plugin_name.'/admin/admin.php'))); |
---|
| 52 | return $menu; |
---|
| 53 | } |
---|
| 54 | function get_template($file) |
---|
| 55 | { |
---|
| 56 | global $user, $template; |
---|
[6921] | 57 | $r_theme_file=array(); |
---|
| 58 | $dir = $this->plugin_path.'template/'; |
---|
| 59 | $r_theme_file=($template->smarty->template_dir); |
---|
| 60 | foreach( $r_theme_file as $style) |
---|
| 61 | { |
---|
| 62 | $theme_file = explode("/", $style); |
---|
| 63 | $pos = count($theme_file) - 2 ; |
---|
| 64 | $theme_file = $dir.$theme_file[$pos].'/'.$file; |
---|
| 65 | if (file_exists($theme_file)) |
---|
| 66 | { |
---|
| 67 | return $theme_file; |
---|
| 68 | } |
---|
| 69 | else |
---|
| 70 | { |
---|
| 71 | $theme_file=NULL; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | } |
---|
| 76 | if (empty($theme_file)) |
---|
| 77 | { |
---|
| 78 | return $dir.'default/'.$file; |
---|
| 79 | } |
---|
[4078] | 80 | } |
---|
| 81 | |
---|
| 82 | function set_block_on_index () |
---|
| 83 | { |
---|
[4080] | 84 | $this->loading_lang(); |
---|
| 85 | global $page, $template, $user, $conf; |
---|
[4078] | 86 | |
---|
| 87 | if (isset($page['section']) and $page['section'] == 'categories') |
---|
[4080] | 88 | |
---|
[4078] | 89 | { |
---|
[4080] | 90 | ////////////lié à quoi///// |
---|
| 91 | $query = ' |
---|
| 92 | SELECT id FROM '.GROUPS_TABLE.' |
---|
| 93 | WHERE name IN (\'+18\') |
---|
| 94 | ;'; |
---|
| 95 | $data_18 = mysql_fetch_array(pwg_query($query)); |
---|
| 96 | $query = ' |
---|
| 97 | SELECT id FROM '.GROUPS_TABLE.' |
---|
| 98 | WHERE name IN (\'16-17\') |
---|
| 99 | ;'; |
---|
| 100 | $data_16 = mysql_fetch_array(pwg_query($query)); |
---|
| 101 | $query = ' |
---|
| 102 | SELECT id FROM '.GROUPS_TABLE.' |
---|
| 103 | WHERE name IN (\'nothing\') |
---|
| 104 | ;'; |
---|
| 105 | $data_no = mysql_fetch_array(pwg_query($query)); |
---|
| 106 | $n_query = ' |
---|
| 107 | SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.' |
---|
| 108 | WHERE group_id IN (\''.$data_18['id'].'\',\''.$data_16['id'].'\',\''.$data_no['id'].'\') AND user_id IN (\''.$user['id'].'\') |
---|
| 109 | ;'; |
---|
| 110 | $data_user = mysql_fetch_array(pwg_query($n_query)); |
---|
| 111 | $is_grouped = $data_user['result']; |
---|
| 112 | |
---|
| 113 | if ( $is_grouped == 0 and $user['username'] !== '16' and $user['username'] !== '18') |
---|
| 114 | { |
---|
[4078] | 115 | $template->set_filename('ac_block', realpath($this->get_template('block.tpl') ) ); |
---|
| 116 | $begin = 'PLUGIN_INDEX_CONTENT_BEFORE'; |
---|
| 117 | $end = 'PLUGIN_INDEX_CONTENT_AFTER'; |
---|
| 118 | $template->concat($begin, $template->parse('ac_block', true)); |
---|
[4080] | 119 | } |
---|
[4078] | 120 | } |
---|
| 121 | } |
---|
[3331] | 122 | function placer_identification($menu_ref_arr) |
---|
| 123 | { |
---|
| 124 | ///////////////////////[début du plug]//////////////////// |
---|
| 125 | $this->loading_lang(); |
---|
| 126 | global $user, $conf, $page; |
---|
| 127 | global $template; |
---|
| 128 | |
---|
| 129 | $menu = & $menu_ref_arr[0]; |
---|
| 130 | |
---|
| 131 | $template->assign( |
---|
| 132 | array( |
---|
| 133 | 'AC_NAME' => AC_NAME |
---|
| 134 | )); |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | //include($this->var_template()); |
---|
| 138 | if (is_a_guest()) |
---|
| 139 | { |
---|
| 140 | |
---|
| 141 | ///////////////////////[gestion fermer/ouvert]//////////////////// |
---|
| 142 | if ( !isset( $_GET['ad'] ) ) |
---|
| 143 | { |
---|
| 144 | if ( !isset( $_COOKIE['pwg_adult_content'] ) or $_COOKIE['pwg_adult_content'] == 'open' ) |
---|
| 145 | { |
---|
| 146 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'closed') )); |
---|
| 147 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 148 | $block->set_title(l10n('ac_title_menu')); |
---|
[4078] | 149 | $block->template = $this->get_template('opened.tpl'); |
---|
[3331] | 150 | } |
---|
| 151 | } |
---|
| 152 | elseif ( $_COOKIE['pwg_adult_content'] == 'closed' ) |
---|
| 153 | { |
---|
| 154 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'open') )); |
---|
| 155 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 156 | $block->set_title(l10n('ac_title_fermer')); |
---|
[4078] | 157 | $block->template = $this->get_template('closed.tpl'); |
---|
[3331] | 158 | } |
---|
| 159 | |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | elseif ( $_GET['ad'] == 'closed' ) |
---|
| 163 | { |
---|
| 164 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'open') )); |
---|
| 165 | setcookie( 'pwg_adult_content', 'closed', time()+60*60*24*30, cookie_path() ); |
---|
| 166 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 167 | $block->set_title(l10n('ac_title_fermer')); |
---|
[4078] | 168 | $block->template = $this->get_template('closed.tpl'); |
---|
[3331] | 169 | } |
---|
| 170 | } |
---|
| 171 | elseif ( $_GET['ad'] == 'open' ) |
---|
| 172 | { |
---|
| 173 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'closed') )); |
---|
| 174 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 175 | $block->set_title(l10n('ac_title_menu')); |
---|
[4078] | 176 | $block->template = $this->get_template('opened.tpl'); |
---|
[3331] | 177 | } |
---|
| 178 | |
---|
| 179 | setcookie( 'pwg_adult_content', 'open', time()+60*60*24*30, cookie_path() ); |
---|
| 180 | } |
---|
| 181 | ///////////////////////[FIN fermer/ouvert]//////////////////// |
---|
| 182 | }//fin if guest |
---|
| 183 | elseif ($user['username'] == '18') |
---|
| 184 | { |
---|
[3494] | 185 | $menu->hide_block('mbIdentification'); |
---|
| 186 | $template->assign( |
---|
| 187 | array( |
---|
| 188 | 'AC_MSG' => l10n('ac_user_text_18') |
---|
| 189 | )); |
---|
| 190 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 191 | $block->set_title(l10n('ac_title_menu')); |
---|
[4078] | 192 | $block->template = $this->get_template('msg.tpl'); |
---|
[3494] | 193 | } |
---|
[3331] | 194 | |
---|
| 195 | $_SESSION['age']="18"; |
---|
| 196 | setcookie( 'age', '18', time()+60*60*24*30, cookie_path() ); |
---|
| 197 | |
---|
| 198 | }//fin if 18 ans |
---|
| 199 | elseif ($user['username'] == '16') |
---|
| 200 | { |
---|
[3494] | 201 | $menu->hide_block('mbIdentification'); |
---|
| 202 | $template->assign( |
---|
| 203 | array( |
---|
| 204 | 'AC_MSG' => l10n('ac_user_text_16') |
---|
| 205 | )); |
---|
| 206 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 207 | $block->set_title(l10n('ac_title_menu')); |
---|
[4078] | 208 | $block->template = $this->get_template('msg.tpl'); |
---|
[3494] | 209 | } |
---|
[3331] | 210 | |
---|
| 211 | }//fin if 16-17 ans |
---|
| 212 | elseif (!is_admin()) |
---|
| 213 | { |
---|
| 214 | |
---|
| 215 | ////////////lié à quoi///// |
---|
| 216 | $query = ' |
---|
| 217 | SELECT id FROM '.GROUPS_TABLE.' |
---|
| 218 | WHERE name IN (\'+18\') |
---|
| 219 | ;'; |
---|
| 220 | $data_18 = mysql_fetch_array(pwg_query($query)); |
---|
| 221 | $query = ' |
---|
| 222 | SELECT id FROM '.GROUPS_TABLE.' |
---|
| 223 | WHERE name IN (\'16-17\') |
---|
| 224 | ;'; |
---|
| 225 | $data_16 = mysql_fetch_array(pwg_query($query)); |
---|
| 226 | $query = ' |
---|
| 227 | SELECT id FROM '.GROUPS_TABLE.' |
---|
| 228 | WHERE name IN (\'nothing\') |
---|
| 229 | ;'; |
---|
| 230 | $data_no = mysql_fetch_array(pwg_query($query)); |
---|
| 231 | $n_query = ' |
---|
| 232 | SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.' |
---|
| 233 | WHERE group_id IN (\''.$data_18['id'].'\',\''.$data_16['id'].'\',\''.$data_no['id'].'\') AND user_id IN (\''.$user['id'].'\') |
---|
| 234 | ;'; |
---|
| 235 | $data_user = mysql_fetch_array(pwg_query($n_query)); |
---|
| 236 | $is_grouped = $data_user['result']; |
---|
| 237 | |
---|
| 238 | if ( $is_grouped == 0 ) |
---|
| 239 | { |
---|
[3494] | 240 | $template->assign( |
---|
| 241 | array( |
---|
| 242 | 'AC_ETAT' => 'not_defined', |
---|
| 243 | 'AC_MSG' => l10n('ac_charte_user_not') |
---|
| 244 | )); |
---|
| 245 | $menu = & $menu_ref_arr[0]; |
---|
| 246 | $block = $menu->get_block( 'mbAdultContent' ); |
---|
| 247 | $block->set_title(l10n('ac_title_choose')); |
---|
[6940] | 248 | $block->template = $this->get_template('choose.tpl'); |
---|
[3494] | 249 | |
---|
[3331] | 250 | } |
---|
| 251 | else |
---|
| 252 | { |
---|
[3494] | 253 | $query = ' |
---|
| 254 | SELECT group_id FROM '.USER_GROUP_TABLE.' |
---|
| 255 | WHERE user_id IN (\''.$user['id'].'\') |
---|
| 256 | ;'; |
---|
| 257 | $data_group = mysql_fetch_array(pwg_query($query)); |
---|
| 258 | $query = ' |
---|
| 259 | SELECT name FROM '.GROUPS_TABLE.' |
---|
| 260 | WHERE id IN (\''.$data_group['group_id'].'\') |
---|
| 261 | ;'; |
---|
| 262 | $data_group_n = mysql_fetch_array(pwg_query($query)); |
---|
| 263 | if ($data_group_n['name'] == '+18') |
---|
| 264 | { |
---|
| 265 | $statut = l10n('ac_user_text_18'); |
---|
| 266 | } |
---|
| 267 | if ($data_group_n['name'] == '16-17') |
---|
| 268 | { |
---|
| 269 | $statut = l10n('ac_user_text_16'); |
---|
| 270 | } |
---|
| 271 | if ($data_group_n['name'] == 'nothing') |
---|
| 272 | { |
---|
| 273 | $statut = l10n('ac_user_no_s'); |
---|
| 274 | } |
---|
| 275 | $template->assign( |
---|
| 276 | array( |
---|
| 277 | 'AC_ETAT' => 'defined', |
---|
| 278 | 'AC_MSG' => $statut.". ".l10n('ac_charte_user_def') |
---|
| 279 | )); |
---|
| 280 | $menu = & $menu_ref_arr[0]; |
---|
| 281 | $block = $menu->get_block( 'mbAdultContent' ); |
---|
| 282 | $block->set_title(l10n('ac_title_menu_statut')); |
---|
[6940] | 283 | $block->template = $this->get_template('choose.tpl'); |
---|
[3494] | 284 | |
---|
[3331] | 285 | } |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | }//fin placer_identification |
---|
| 289 | function on_register() |
---|
| 290 | { |
---|
| 291 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
| 292 | $user_id = get_userid($_POST['login']); |
---|
| 293 | log_user( $user_id, false); |
---|
| 294 | redirect(PHPWG_ROOT_PATH.'plugins/adult_content/charte_user.php?etat=not_defined'); |
---|
| 295 | } |
---|
| 296 | }//fin class |
---|
| 297 | ?> |
---|