Changeset 21047 for extensions/adult_content/maintain.inc.php
- Timestamp:
- Feb 26, 2013, 8:50:03 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/adult_content/maintain.inc.php
r12622 r21047 3 3 function plugin_install() 4 4 { 5 5 global $conf; 6 6 7 7 ////////////créer groupe//////////// 8 8 $query = ' 9 9 INSERT INTO '.GROUPS_TABLE.' 10 10 (name) … … 12 12 (\'+18\') 13 13 ;'; 14 15 14 pwg_query($query); 15 $query = ' 16 16 INSERT INTO '.GROUPS_TABLE.' 17 17 (name) … … 19 19 (\'16-17\') 20 20 ;'; 21 22 21 pwg_query($query); 22 $query = ' 23 23 INSERT INTO '.GROUPS_TABLE.' 24 24 (name) … … 26 26 (\'nothing\') 27 27 ;'; 28 28 pwg_query($query); 29 29 ////////////créer user//////////// 30 30 include_once(PHPWG_ROOT_PATH.'include/functions_user.inc.php'); … … 34 34 ////////////placer dans group 16//////////// 35 35 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;'); 36 $data_group = mysql_fetch_array($result);36 $data_group = pwg_db_fetch_array($result); 37 37 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' ); 38 38 39 39 ////////////placer dans group 18//////////// 40 40 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;'); 41 $data_group = mysql_fetch_array($result);41 $data_group = pwg_db_fetch_array($result); 42 42 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' ); 43 43 44 ////////////placer dans group nothing//////////// 45 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'nothing\') ;'); 46 $data_group = pwg_db_fetch_array($result); 47 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.$conf['guest_id'].'\', \''.$data_group['id'].'\' )' ); 48 44 49 /////////////Config plugin 50 $config_start=array('menublock_for_guest'=>true,'block_on_index'=>false,'manage_what'=>'both'); 45 51 $q = ' 46 52 INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) 47 53 VALUES 48 ("ad_c_plugin" , " true,false,both" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");';54 ("ad_c_plugin" , "'.pwg_db_real_escape_string(serialize($config_start)).'" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");'; 49 55 pwg_query($q); 50 56 … … 55 61 function plugin_activate() 56 62 { 57 ///user exist ?/// 63 global $conf; 64 ///user exist ?/// 58 65 $query = ' 59 66 SELECT COUNT(*) AS result FROM '.USERS_TABLE.' 60 67 WHERE username IN (\'18\') 61 68 ;'; 62 $data_user = mysql_fetch_array(pwg_query($query));69 $data_user = pwg_db_fetch_array(pwg_query($query)); 63 70 $exist = $data_user['result']; 64 71 if ( $exist == 0 ) … … 71 78 WHERE username IN (\'16\') 72 79 ;'; 73 $data_user = mysql_fetch_array(pwg_query($query));80 $data_user = pwg_db_fetch_array(pwg_query($query)); 74 81 $exist = $data_user['result']; 75 82 if ( $exist == 0 ) … … 77 84 register_user('16', 'adult_content', ''); 78 85 } 79 ///group exist ?/// 80 $query = ' 81 SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.' 82 WHERE name IN (\'+18\') 83 ;'; 84 $data_user = mysql_fetch_array(pwg_query($query)); 85 $exist = $data_user['result']; 86 if ( $exist == 0 ) 87 { 88 $query = 'INSERT INTO '.GROUPS_TABLE.' 89 (name) 90 VALUES 91 (\'+18\') 92 ;'; 93 pwg_query($query); 94 ////////////placer dans group 18//////////// 95 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;'); 96 $data_group = mysql_fetch_array($result); 97 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' ); 98 } 99 100 $query = ' 101 SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.' 102 WHERE name IN (\'16-17\') 103 ;'; 104 $data_user = mysql_fetch_array(pwg_query($query)); 105 $exist = $data_user['result']; 106 if ( $exist == 0 ) 107 { 108 $query = ' 109 INSERT INTO '.GROUPS_TABLE.' 110 (name) 111 VALUES 112 (\'16-17\') 113 ;'; 114 pwg_query($query); 86 ///groups/// 87 $query = 'INSERT IGNORE INTO '.GROUPS_TABLE.' (name) VALUES (\'+18\'),(\'16-17\'),(\'nothing\') ;'; 88 pwg_query($query); 89 ////////////placer dans group 18//////////// 90 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;'); 91 $data_group = pwg_db_fetch_array($result); 92 pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' ); 115 93 ////////////placer dans group 16//////////// 116 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;'); 117 $data_group = mysql_fetch_array($result); 118 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' ); 119 120 } 121 //grp nothing 122 $query = ' 123 SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.' 124 WHERE name IN (\'nothing\') 125 ;'; 126 $data_user = mysql_fetch_array(pwg_query($query)); 127 $exist = $data_user['result']; 128 if ( $exist == 0 ) 129 { 130 $query = ' 131 INSERT INTO '.GROUPS_TABLE.' 132 (name) 133 VALUES 134 (\'nothing\') 135 ;'; 136 pwg_query($query); 137 } 138 139 ///assoc user/group exist ?/// 140 141 $n_query = ' 142 SELECT id FROM '.GROUPS_TABLE.' 143 WHERE name IN (\'16-17\') 144 ;'; 145 $data_group = mysql_fetch_array(pwg_query($n_query)); 146 $query = ' 147 SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.' 148 WHERE group_id IN (\''.$data_group['id'].'\') AND user_id IN (\''.get_userid('16').'\') 149 ;'; 150 $data_user_group = mysql_fetch_array(pwg_query($query)); 151 $exist = $data_user_group['result']; 152 if ( $exist == 0 ) 153 { 154 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' ); 155 } 156 $n_query = ' 157 SELECT id FROM '.GROUPS_TABLE.' 158 WHERE name IN (\'+18\') 159 ;'; 160 $data_group = mysql_fetch_array(pwg_query($n_query)); 161 $query = ' 162 SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.' 163 WHERE group_id IN (\''.$data_group['id'].'\') AND user_id IN (\''.get_userid('18').'\') 164 ;'; 165 $data_user_group = mysql_fetch_array(pwg_query($query)); 166 $exist = $data_user_group['result']; 167 if ( $exist == 0 ) 168 { 169 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' ); 170 } 94 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;'); 95 $data_group = pwg_db_fetch_array($result); 96 pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' ); 97 ////////////placer dans group nothing//////////// 98 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'nothing\') ;'); 99 $data_group = pwg_db_fetch_array($result); 100 pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.$conf['guest_id'].'\', \''.$data_group['id'].'\' )' ); 171 101 172 102 ////////////mis en generic//////////// … … 190 120 WHERE param IN (\'ad_c_plugin\') 191 121 ;'; 192 $data_table = mysql_fetch_array(pwg_query($query));122 $data_table = pwg_db_fetch_array(pwg_query($query)); 193 123 $exist = $data_table['result']; 194 124 if ( $exist == 0 ) 195 125 { 196 $q = ' 197 INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) 198 VALUES 199 ("ad_c_plugin" , "true,false,both" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");'; 200 pwg_query($q); 126 $config_start=array('menublock_for_guest'=>true,'block_on_index'=>false,'manage_what'=>'both'); 127 $q = ' 128 INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) 129 VALUES 130 ("ad_c_plugin" , "'.pwg_db_real_escape_string(serialize($config_start)).'" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");'; 131 pwg_query($q); 201 132 } 202 133 else { 203 134 $query = ' 204 205 206 207 $data_conf = mysql_fetch_array(pwg_query($query));208 $conf=explode(',', $data_conf['value']);209 $nbr=count($conf);210 211 if ($nbr!=3)212 {213 pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'ad_c_plugin\')');214 215 INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) 216 VALUES 217 ("ad_c_plugin" , "true,false,both" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");';218 219 135 SELECT value FROM '.CONFIG_TABLE.' 136 WHERE param IN (\'ad_c_plugin\') 137 ;'; 138 $data_conf = pwg_db_fetch_array(pwg_query($query)); 139 $cf=@unserialize($data_conf); 140 $nbr=count($cf); 141 142 if ($nbr!=3) 143 { 144 $config_start=array('menublock_for_guest'=>true,'block_on_index'=>false,'manage_what'=>'both'); 145 $q = ' 146 UPDATE ' . CONFIG_TABLE . ' SET 147 param="ad_c_plugin", value="'.pwg_db_real_escape_string(serialize($config_start)).'", comment="Plugin adult_content : menublock_for_guest, block_on_index, manage_what" 148 WHERE param IN (\'ad_c_plugin\');'; 149 pwg_query($q); 150 } 220 151 } 221 152 … … 237 168 WHERE name IN (\'16-17\') 238 169 ;'; 239 $data_group = mysql_fetch_array(pwg_query($query));170 $data_group = pwg_db_fetch_array(pwg_query($query)); 240 171 pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' ); 241 172 … … 245 176 WHERE name IN (\'+18\') 246 177 ;'; 247 $data_group = mysql_fetch_array(pwg_query($query));178 $data_group = pwg_db_fetch_array(pwg_query($query)); 248 179 pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' ); 249 180 … … 253 184 WHERE name IN (\'nothing\') 254 185 ;'; 255 $data_group = mysql_fetch_array(pwg_query($query));186 $data_group = pwg_db_fetch_array(pwg_query($query)); 256 187 pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' ); 257 188
Note: See TracChangeset
for help on using the changeset viewer.