| 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 | 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; |
|---|
| 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 | } |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | function set_block_on_index () |
|---|
| 83 | { |
|---|
| 84 | $this->loading_lang(); |
|---|
| 85 | global $page, $template, $user, $conf; |
|---|
| 86 | |
|---|
| 87 | if (isset($page['section']) and $page['section'] == 'categories') |
|---|
| 88 | |
|---|
| 89 | { |
|---|
| 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 | { |
|---|
| 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)); |
|---|
| 119 | } |
|---|
| 120 | } |
|---|
| 121 | } |
|---|
| 122 | function placer_identification($menu_ref_arr) |
|---|
| 123 | { |
|---|
| 124 | ///////////////////////[début du plug]//////////////////// |
|---|
| 125 | $this->loading_lang(); |
|---|
| 126 | global $user, $conf, $page, $template; |
|---|
| 127 | $menu = & $menu_ref_arr[0]; |
|---|
| 128 | $conf_plugin = explode("," , $conf['ad_c_plugin']); |
|---|
| 129 | $template->assign( |
|---|
| 130 | array( |
|---|
| 131 | 'AC_NAME' => AC_NAME |
|---|
| 132 | )); |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | //include($this->var_template()); |
|---|
| 136 | if (is_a_guest() and $conf_plugin[0]=='true') |
|---|
| 137 | { |
|---|
| 138 | |
|---|
| 139 | ///////////////////////[gestion fermer/ouvert]//////////////////// |
|---|
| 140 | if ( !isset( $_GET['ad'] ) ) |
|---|
| 141 | { |
|---|
| 142 | if ( !isset( $_COOKIE['pwg_adult_content'] ) or $_COOKIE['pwg_adult_content'] == 'open' ) |
|---|
| 143 | { |
|---|
| 144 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'closed') )); |
|---|
| 145 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
|---|
| 146 | $block->set_title(l10n('ac_title_menu')); |
|---|
| 147 | $block->template = $this->get_template('opened.tpl'); |
|---|
| 148 | } |
|---|
| 149 | } |
|---|
| 150 | elseif ( $_COOKIE['pwg_adult_content'] == 'closed' ) |
|---|
| 151 | { |
|---|
| 152 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'open') )); |
|---|
| 153 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
|---|
| 154 | $block->set_title(l10n('ac_title_fermer')); |
|---|
| 155 | $block->template = $this->get_template('closed.tpl'); |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | } |
|---|
| 159 | } |
|---|
| 160 | elseif ( $_GET['ad'] == 'closed' ) |
|---|
| 161 | { |
|---|
| 162 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'open') )); |
|---|
| 163 | setcookie( 'pwg_adult_content', 'closed', time()+60*60*24*30, cookie_path() ); |
|---|
| 164 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
|---|
| 165 | $block->set_title(l10n('ac_title_fermer')); |
|---|
| 166 | $block->template = $this->get_template('closed.tpl'); |
|---|
| 167 | } |
|---|
| 168 | } |
|---|
| 169 | elseif ( $_GET['ad'] == 'open' ) |
|---|
| 170 | { |
|---|
| 171 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'closed') )); |
|---|
| 172 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
|---|
| 173 | $block->set_title(l10n('ac_title_menu')); |
|---|
| 174 | $block->template = $this->get_template('opened.tpl'); |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | setcookie( 'pwg_adult_content', 'open', time()+60*60*24*30, cookie_path() ); |
|---|
| 178 | } |
|---|
| 179 | ///////////////////////[FIN fermer/ouvert]//////////////////// |
|---|
| 180 | }//fin if guest |
|---|
| 181 | elseif (is_a_guest() and $conf_plugin[0]!='true') |
|---|
| 182 | { |
|---|
| 183 | $menu->hide_block('mbAdultContent'); |
|---|
| 184 | } |
|---|
| 185 | elseif ($user['username'] == '18') |
|---|
| 186 | { |
|---|
| 187 | $menu->hide_block('mbIdentification'); |
|---|
| 188 | $template->assign( |
|---|
| 189 | array( |
|---|
| 190 | 'AC_MSG' => l10n('ac_user_text_18') |
|---|
| 191 | )); |
|---|
| 192 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
|---|
| 193 | $block->set_title(l10n('ac_title_menu')); |
|---|
| 194 | $block->template = $this->get_template('msg.tpl'); |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| 197 | $_SESSION['age']="18"; |
|---|
| 198 | setcookie( 'age', '18', time()+60*60*24*30, cookie_path() ); |
|---|
| 199 | |
|---|
| 200 | }//fin if 18 ans |
|---|
| 201 | elseif ($user['username'] == '16') |
|---|
| 202 | { |
|---|
| 203 | $menu->hide_block('mbIdentification'); |
|---|
| 204 | $template->assign( |
|---|
| 205 | array( |
|---|
| 206 | 'AC_MSG' => l10n('ac_user_text_16') |
|---|
| 207 | )); |
|---|
| 208 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
|---|
| 209 | $block->set_title(l10n('ac_title_menu')); |
|---|
| 210 | $block->template = $this->get_template('msg.tpl'); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | }//fin if 16-17 ans |
|---|
| 214 | elseif (!is_admin()) |
|---|
| 215 | { |
|---|
| 216 | |
|---|
| 217 | ////////////lié à quoi///// |
|---|
| 218 | $query = ' |
|---|
| 219 | SELECT id FROM '.GROUPS_TABLE.' |
|---|
| 220 | WHERE name IN (\'+18\') |
|---|
| 221 | ;'; |
|---|
| 222 | $data_18 = mysql_fetch_array(pwg_query($query)); |
|---|
| 223 | $query = ' |
|---|
| 224 | SELECT id FROM '.GROUPS_TABLE.' |
|---|
| 225 | WHERE name IN (\'16-17\') |
|---|
| 226 | ;'; |
|---|
| 227 | $data_16 = mysql_fetch_array(pwg_query($query)); |
|---|
| 228 | $query = ' |
|---|
| 229 | SELECT id FROM '.GROUPS_TABLE.' |
|---|
| 230 | WHERE name IN (\'nothing\') |
|---|
| 231 | ;'; |
|---|
| 232 | $data_no = mysql_fetch_array(pwg_query($query)); |
|---|
| 233 | $n_query = ' |
|---|
| 234 | SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.' |
|---|
| 235 | WHERE group_id IN (\''.$data_18['id'].'\',\''.$data_16['id'].'\',\''.$data_no['id'].'\') AND user_id IN (\''.$user['id'].'\') |
|---|
| 236 | ;'; |
|---|
| 237 | $data_user = mysql_fetch_array(pwg_query($n_query)); |
|---|
| 238 | $is_grouped = $data_user['result']; |
|---|
| 239 | |
|---|
| 240 | if ( $is_grouped == 0 ) |
|---|
| 241 | { |
|---|
| 242 | $template->assign( |
|---|
| 243 | array( |
|---|
| 244 | 'AC_ETAT' => 'not_defined', |
|---|
| 245 | 'AC_MSG' => l10n('ac_charte_user_not') |
|---|
| 246 | )); |
|---|
| 247 | $menu = & $menu_ref_arr[0]; |
|---|
| 248 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
|---|
| 249 | $block->set_title(l10n('ac_title_choose')); |
|---|
| 250 | $block->template = $this->get_template('choose.tpl'); |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | } |
|---|
| 254 | else |
|---|
| 255 | { |
|---|
| 256 | $query = ' |
|---|
| 257 | SELECT group_id FROM '.USER_GROUP_TABLE.' |
|---|
| 258 | WHERE user_id IN (\''.$user['id'].'\') |
|---|
| 259 | ;'; |
|---|
| 260 | $data_group = mysql_fetch_array(pwg_query($query)); |
|---|
| 261 | $query = ' |
|---|
| 262 | SELECT name FROM '.GROUPS_TABLE.' |
|---|
| 263 | WHERE id IN (\''.$data_group['group_id'].'\') |
|---|
| 264 | ;'; |
|---|
| 265 | $data_group_n = mysql_fetch_array(pwg_query($query)); |
|---|
| 266 | if ($data_group_n['name'] == '+18') |
|---|
| 267 | { |
|---|
| 268 | $statut = l10n('ac_user_text_18'); |
|---|
| 269 | } |
|---|
| 270 | if ($data_group_n['name'] == '16-17') |
|---|
| 271 | { |
|---|
| 272 | $statut = l10n('ac_user_text_16'); |
|---|
| 273 | } |
|---|
| 274 | if ($data_group_n['name'] == 'nothing') |
|---|
| 275 | { |
|---|
| 276 | $statut = l10n('ac_user_no_s'); |
|---|
| 277 | } |
|---|
| 278 | $template->assign( |
|---|
| 279 | array( |
|---|
| 280 | 'AC_ETAT' => 'defined', |
|---|
| 281 | 'AC_MSG' => $statut.". ".l10n('ac_charte_user_def') |
|---|
| 282 | )); |
|---|
| 283 | $menu = & $menu_ref_arr[0]; |
|---|
| 284 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
|---|
| 285 | $block->set_title(l10n('ac_title_menu_statut')); |
|---|
| 286 | $block->template = $this->get_template('choose.tpl'); |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | } |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | }//fin placer_identification |
|---|
| 293 | function on_register() |
|---|
| 294 | { |
|---|
| 295 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
|---|
| 296 | $user_id = get_userid($_POST['login']); |
|---|
| 297 | log_user( $user_id, false); |
|---|
| 298 | redirect(PHPWG_ROOT_PATH.'plugins/adult_content/charte_user.php?etat=not_defined'); |
|---|
| 299 | } |
|---|
| 300 | }//fin class |
|---|
| 301 | ?> |
|---|