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