$ec_code) { $ec_lists['duplicable_codes']['ids'][$ec_id] = $ec_lists['duplicable_codes']['codes'][$ec_code]['id']; } // Builds a category list displayed a best way build_ec_categories(false); } // +-----------------------------------------------------------------------+ // | Database modifying functions | // +-----------------------------------------------------------------------+ /* * ec_create_entry_OK() * returns true or false whether the creation of a new entry described by * $_POST was OK or not. * * @param * no param * @return * true if creation was OK ; false if not */ function ec_create_entry_OK() { global $page, $ec_lists; /* ( [ec_act1] => create [ec_entry_sel] => -1 [ec_sel_code] => new [ec_in_up_auto_code_length] => 10 [ec_in_up_code] => 94q0V1067D [ec_sel_user] => new [ec_in_up_usr_txt] => san_gimi [ec_in_up_psd_txt] => 7Mv8QxZV [ec_in_up_newgroup] => on [ec_in_up_grp_txt] => EC_san_gimi [ec_input_action] => cat [ec_in_up_cat] => 6 [ec_in_up_img] => ) ( [ec_act1] => create [ec_entry_sel] => -1 [ec_sel_code] => new [ec_in_up_auto_code_length] => 10 [ec_in_up_code] => NU1pah0qVJ [ec_in_up_usr_txt] => [ec_in_up_psd_txt] => [ec_in_up_grp_txt] => [ec_sel_user] => old [ec_in_up_usr_list] => 9 [ec_input_action] => cat [ec_in_up_cat] => 6 [ec_in_up_img] => ) */ // $_POST validity checks : creation prevented in case of bad arguments /* if ( !isset($_POST['ec_in_up_code']) or !ereg('^[a-zA-Z0-9_-]{4,32}$', $_POST['ec_in_up_code']) ) return ec_end1('ec_in_up_code', 'ec_bad_argument7'); foreach ($ec_lists['ec_table'] as $ec_entry) if ($_POST['ec_in_up_code'] == $ec_entry['code']) return ec_end1('ec_in_up_code', 'ec_bad_argument2'); if ( !isset($_POST['ec_sel_user']) or ( $_POST['ec_sel_user'] != 'new' and $_POST['ec_sel_user'] != 'old' ) ) return ec_end1('ec_sel_user', 'ec_bad_argument1'); if ($_POST['ec_sel_user'] == 'new') { if ( !isset($_POST['ec_in_up_usr_txt']) or $_POST['ec_in_up_usr_txt'] == '' ) return ec_end1('ec_in_up_usr_txt', 'ec_bad_argument1'); $t1 = (in_array($_POST['ec_in_up_usr_txt'], $ec_lists['user_ids'])); if ($t1) return ec_end1('ec_in_up_usr_txt', 'ec_bad_argument3'); } else { if (!isset($_POST['ec_in_up_usr_list'])) return ec_end1('ec_in_up_usr_txt', 'ec_bad_argument1'); $ec_user_id = $_POST['ec_in_up_usr_list']; $t1 = (array_key_exists($ec_user_id, $ec_lists['user_ids'])); if (!$t1) return ec_end1('ec_in_up_usr_list', 'ec_bad_argument6'); } // code and user_id (if needed) are OK, creation can be done if ($_POST['ec_sel_user'] == 'new') { $page['errors'] = register_user( $_POST['ec_in_up_usr_txt'], $_POST['ec_in_up_psd_txt'], '', false ); if ( count($page['errors']) != 0 or !($ec_user_id = get_userid($_POST['ec_in_up_usr_txt'])) or !pwg_query(" UPDATE `".USER_INFOS_TABLE."` SET `status` = 'generic' WHERE `user_id` = ".$ec_user_id."; ") ) { array_unshift($page['errors'], l10n('ec_user_create_pb')); return false; } else $page['infos'][] = l10n('ec_user_create_OK').$ec_user_id; if ( isset($_POST['ec_in_up_newgroup']) and isset($_POST['ec_in_up_grp_txt']) and $_POST['ec_in_up_grp_txt'] != '' ) { // New group creation, and association with user_id at the same time if ( !($t = mysql_fetch_row(pwg_query(" SELECT `id` FROM `".GROUPS_TABLE."` WHERE `name` = '".$_POST['ec_in_up_grp_txt']."'; "))) ) { if ( !pwg_query(" INSERT INTO `".GROUPS_TABLE."` (`name`, `is_default`) VALUES ('".$_POST['ec_in_up_grp_txt']."', 'false'); ") ) return ec_end2('ec_group_create_pb', '1'); if ( !($t = mysql_fetch_row(pwg_query(" SELECT `id` FROM `".GROUPS_TABLE."` WHERE `name` = '".$_POST['ec_in_up_grp_txt']."'; "))) ) return ec_end2('ec_group_create_pb', '2'); } if ( !(pwg_query(" INSERT INTO `".USER_GROUP_TABLE."` (`user_id `, `group_id`) VALUES ('".$ec_user_id."', '".$t['id']."'); ")) ) return ec_end2('ec_group_create_pb', '3'); } } else { if ($t1) { $arg1 = ''; $arg2 = ''; switch ($_POST['ec_input_action']) { // case 'home': // Home : nothing to do : "arg"s are '' case 'add_p': // Additional Page break; case 'cat': // Category case 'img': // Image break; default : return ec_end1('ec_input_action', 'ec_bad_argument1'); } else return ec_end1('ec_in_up_code', 'ec_bad_argument7'); } else return ec_end1('ec_in_up_usr_txt', 'ec_bad_argument6'); } */ $page['errors'][] = 'Y\'a p\'tĂȘt\' ben eu une erreur...'; } /* * ec_duplicate_entry_OK() * returns true or false whether the duplication of an existing entry which # * is given by $_POST['ec_entry_sel'] was OK or not. * * @param * no param * @return * true if creation was OK ; false if not */ function ec_duplicate_entry_OK() { global $page, $ec_lists; build_ec_duplicable_codes(); if (array_key_exists($_POST['ec_entry_sel'], $ec_lists['duplicable_codes']['ids'])) { $arg1 = ''; $arg2 = ''; switch ($_POST['ec_input_action']) { case 'add_p': if (array_key_exists($_POST['ec_in_up_aps'],$ec_lists['add_pages'])) { $arg2 = $_POST['ec_in_up_aps']; } else return ec_end1('ec_in_up_aps', 'ec_bad_argument4'); case 'home': break; case 'img': case 'cat': if (array_key_exists($_POST['ec_in_up_cat'], $ec_lists['categories'])) { if ($_POST['ec_input_action'] == 'img') { if ( ec_image_exists($_POST['ec_in_up_cat'], $_POST['ec_in_up_img']) ) $arg2 = $_POST['ec_in_up_img']; else return ec_end1('ec_in_up_img', 'ec_bad_argument4'); } $arg1 = $_POST['ec_in_up_cat']; } else return ec_end1('ec_in_up_cat', 'ec_bad_argument4'); break; default: return ec_end1('ec_input_action', 'ec_bad_argument1'); } if (pwg_query(" INSERT INTO `".EVNTCATS_TABLE."` (`code`, `user_id`, `action`, `arg1`, `arg2`) VALUES ( '".$ec_lists['ec_table'][$_POST['ec_entry_sel']]['code']."', '".$ec_lists['ec_table'][$_POST['ec_entry_sel']]['user_id']."', 'ec_ok', '".$arg1."', '".$arg2."' ); ")) { $page['infos'][] = l10n('ec_entry_dup_ok_pre'). $_POST['ec_entry_sel'].' ('. $ec_lists['ec_table'][$_POST['ec_entry_sel']]['code'].')'. l10n('ec_entry_dup_ok_end') ; build_ec_table(); return true; } else { $page['errors'][] = l10n('ec_entry_dup_nok_pre1'). $_POST['ec_entry_sel']. l10n('ec_entry_dup_nok_end1'). 'MySQL error '.mysql_errno().', "'.mysql_error().'"' ; return false; } } else return ec_end1('ec_entry_sel', 'ec_bad_argument5'); } /* * ec_modify_entry_OK() * returns true or false whether the modification of an existing entry which # * is given by $_POST['ec_entry_sel'] was OK or not. * * @param * no param * @return * true if modification was OK ; false if not */ function ec_modify_entry_OK() { global $page; $page['errors'][] = 'Y\'a pas eu une erreur ?...'; return false; } /* * ec_toggle_forced_entry() * Toggles the 'forced' property of an entry, provided it complies to the * rules. * * @param * no param * @return * no return value */ function ec_toggle_forced_entry() { global $page; $page['errors'][] = 'ec_toggle_forced_entry'; } /* * ec_delete_entry() * tries to delete an existing entry which # is given by * $_POST['ec_entry_sel']. * * @param * no param * @return * no return value : modifies $page['errors'] or $page['infos'] */ function ec_delete_entry() { global $page, $ec_lists; if (array_key_exists($_POST['ec_entry_sel'], $ec_lists['ec_table'])) { if (!pwg_query(' DELETE FROM `'.EVNTCATS_TABLE.'` WHERE `id` = '.$_POST['ec_entry_sel'] )) { $page['errors'][] = l10n('ec_entry_del_nok_pre'). $_POST['ec_entry_sel']. l10n('ec_entry_del_nok_end'). 'MySQL error '.mysql_errno().', "'.mysql_error().'"' ; } else { $page['infos'][] = l10n('ec_entry_del_ok_pre'). $_POST['ec_entry_sel']. l10n('ec_entry_del_ok_end'); build_ec_table(); } } else ec_end1('ec_entry_sel', 'ec_bad_argument1'); } ?>