} elseif ($protectedPost['onglet'] == 'ADMIN_SMTP' and $_SESSION['OCS']['profile']->getConfigValue('MANAGE_SMTP_COMMUNITIES') == 'YES') { if (isset($protectedPost['Valid_modif'])) { $msg_result = add_community($protectedPost['MODIF'], $protectedPost['NAME'], $protectedPost['VERSION'], $protectedPost['USERNAME'], $protectedPost['AUTHKEY'], $protectedPost['AUTHPASSWD']); if (isset($msg_result['SUCCESS'])) { unset($protectedPost['MODIF'], $protectedPost['ADD_COMM']); $msg_ok = $msg_result['SUCCESS']; $tab_options['CACHE'] = 'RESET'; } else { $msg_error = $msg_result['ERROR']; } } if (isset($protectedPost['Reset_modif'])) { unset($protectedPost['MODIF'], $protectedPost['ADD_COMM']); } if (isset($protectedPost['SUP_PROF']) and is_numeric($protectedPost['SUP_PROF'])) { del_community($protectedPost['SUP_PROF']); $msg_ok = $l->g(1212); } if (isset($msg_ok)) { msg_success($msg_ok); } if (isset($msg_error)) { msg_error($msg_error); } if ($protectedPost['ADD_COMM'] == $l->g(116) or is_numeric($protectedPost['MODIF'])) { $list_version = array('-1' => '2c', '1' => '1', '2' => '2', '3' => '3'); $title = $l->g(1207); if (isset($protectedPost['MODIF']) and is_numeric($protectedPost['MODIF']) and !isset($protectedPost['NAME'])) { $info_com = find_community_info($protectedPost['MODIF']); $default_values = array('ID' => $protectedPost['MODIF'], 'NAME' => $info_com->NAME, 'VERSION' => $list_version, 'USERNAME' => $info_com->USERNAME, 'AUTHKEY' => $info_com->AUTHKEY, 'AUTHPASSWD' => $info_com->AUTHPASSWD); if ($info_com->VERSION == "2c") {
function add_community($ID, $NAME, $VERSION, $USERNAME, $AUTHKEY, $AUTHPASSWD) { global $l; if ($VERSION == -1) { $VERSION = '2c'; } //this name of community still exist? $sql = "select name from snmp_communities where name='%s' and version='%s' "; $arg = array($NAME, $VERSION); if (isset($ID) and is_numeric($ID)) { $sql .= " and id != %s"; array_push($arg, $ID); } $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); $row = mysqli_fetch_object($res); //Exist if (isset($row->name)) { return array('ERROR' => $NAME . " " . $l->g(363)); } if (isset($ID) and is_numeric($ID)) { del_community($ID); $SUCCESS = $l->g(1209); } else { $SUCCESS = $l->g(1208); } $sql = "insert into snmp_communities (ID,VERSION,NAME,USERNAME,AUTHKEY,AUTHPASSWD) VALUES ('%s','%s','%s','%s','%s','%s')"; $arg = array($ID, $VERSION, $NAME, $USERNAME, $AUTHKEY, $AUTHPASSWD); mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); return array('SUCCESS' => $SUCCESS); }