185
185
}elseif($protectedPost['onglet'] == 'ADMIN_SMTP'
186
186
and $_SESSION['OCS']['CONFIGURATION']['MANAGE_SMTP_COMMUNITIES'] == 'YES'){
187
$file='snmp_com.txt';
190
$search=array('ID','NAME','VERSION',
191
'USERNAME','AUTHKEY','AUTHPASSWD');
192
$snmp_dir=look_config_default_values('SNMP_DIR');
193
if (isset($snmp_dir['tvalue']['SNMP_DIR']) and $snmp_dir['tvalue']['SNMP_DIR'] != '')
194
$ms_cfg_file=$snmp_dir['tvalue']['SNMP_DIR'];
196
$ms_cfg_file= DOCUMENT_ROOT.'snmp/';
198
if (!file_exists($ms_cfg_file))
199
$error=$l->g(920) . " (".$ms_cfg_file.") <br>";
200
if (!is_writable($ms_cfg_file))
201
$error=$ms_cfg_file." ".$l->g(1006).". ".$l->g(1147);
203
$ms_cfg_file.="/".$file;
205
if (!is_writable($ms_cfg_file) and file_exists($ms_cfg_file))
206
$error.=$ms_cfg_file." ".$l->g(1006)."<br>";
212
if (file_exists($ms_cfg_file)){
213
$field_com=parse_xml_file($ms_cfg_file,$search,"COMMUNITY");
216
while($field_com[$i]){
217
if ($field_com[$i]['ID'] > $id_value)
218
$id_value=$field_com[$i]['ID'];
222
if ($protectedPost['Valid_modif_x']){
224
if (($protectedPost['VERSION'] != '3a' and trim($protectedPost['NAME']) != '') or
225
($protectedPost['VERSION'] == '3a' and trim($protectedPost['NAME']) != '' and
226
trim($protectedPost['USERNAME']) != '' and
227
trim($protectedPost['AUTHKEY']) != '' and
228
trim($protectedPost['AUTHPASSWD']) != '')){
229
$snmp_value=format_value_community($protectedPost);
188
if (isset($protectedPost['Valid_modif_x'])){
189
$msg_result=add_community($protectedPost['MODIF'],$protectedPost['NAME'],$protectedPost['VERSION'],
190
$protectedPost['USERNAME'],$protectedPost['AUTHKEY'],
191
$protectedPost['AUTHPASSWD']);
192
if (isset($msg_result['SUCCESS'])){
193
unset($protectedPost['MODIF'],$protectedPost['ADD_COMM']);
194
$msg_ok=$msg_result['SUCCESS'];
195
$tab_options['CACHE']='RESET';
197
$msg_error=$msg_result['ERROR'];
233
if (is_array($snmp_value)){
235
if (isset($protectedPost['MODIF']) and $protectedPost['MODIF'] != ''){
236
del_community(array($protectedPost['MODIF']),$ms_cfg_file,$search);
237
$snmp_value['ID']=$protectedPost['MODIF'];
239
}elseif (file_exists($ms_cfg_file)){
241
//$field_com=parse_xml_file($ms_cfg_file,$search,"COMMUNITY");
243
while ($field_com[$i]){
244
if ($field_com[$i]['ID'] == $snmp_value['ID']){
252
$field_com=parse_xml_file($ms_cfg_file,$search,"COMMUNITY");
253
$new_ms_cfg_file=add_community($snmp_value,$field_com);
254
$file=fopen($ms_cfg_file,"w+");
255
fwrite($file,$new_ms_cfg_file);
257
$field_com=parse_xml_file($ms_cfg_file,$search,"COMMUNITY");
259
unset($protectedPost['MODIF'],$protectedPost['ADD_COMM']);
265
202
if (isset($protectedPost['Reset_modif_x'])){
266
203
unset($protectedPost['MODIF'],$protectedPost['ADD_COMM']);
269
206
if (isset($protectedPost['SUP_PROF']) and is_numeric($protectedPost['SUP_PROF'])){
270
del_community(array($protectedPost['SUP_PROF']),$ms_cfg_file,$search);
207
del_community($protectedPost['SUP_PROF']);
271
208
$msg_ok=$l->g(1212);
274
if (!file_exists($ms_cfg_file) or $protectedPost['ADD_COMM'] == $l->g(116) or is_numeric($protectedPost['MODIF'])){
275
if (isset($id_value)){
276
$protectedPost['ID']=$id_value+1;
278
$protectedPost['ID']=0;
213
msg_success($msg_ok);
215
if (isset($msg_error))
216
msg_error($msg_error);
218
if ($protectedPost['ADD_COMM'] == $l->g(116) or is_numeric($protectedPost['MODIF'])){
280
$list_version=array('2c'=>'2c','1a'=>'1','2a'=>'2'/*,'3a'=>'3'*/);
220
$list_version=array('-1'=>'2c','1'=>'1','2'=>'2',/*'3'=>'3'*/);
281
221
$title=$l->g(1207);
282
222
if (isset($protectedPost['MODIF']) and is_numeric($protectedPost['MODIF']) and !isset($protectedPost['NAME'])){
283
$info_com=find_community_info($protectedPost['MODIF'],$ms_cfg_file,$search);
223
$info_com=find_community_info($protectedPost['MODIF']);
284
224
$default_values=array('ID'=>$protectedPost['MODIF'],
285
'NAME'=>$info_com['NAME'],
225
'NAME'=>$info_com->NAME,
286
226
'VERSION' =>$list_version,
287
'USERNAME' =>$info_com['USERNAME'],
288
'AUTHKEY'=>$info_com['AUTHKEY'],
289
'AUTHPASSWD'=>$info_com['AUTHPASSWD']);
290
if ($info_com['VERSION'] != '2c')
291
$protectedPost['VERSION']=$info_com['VERSION'].'a';
227
'USERNAME' =>$info_com->USERNAME,
228
'AUTHKEY'=>$info_com->AUTHKEY,
229
'AUTHPASSWD'=>$info_com->AUTHPASSWD);
230
if ($info_com->VERSION == "2c")
231
$protectedPost['VERSION']=-1;
293
$protectedPost['VERSION']=$info_com['VERSION'];
233
$protectedPost['VERSION']=$info_com->VERSION;
296
236
$default_values=array('ID'=>$protectedPost['ID'],
303
243
form_add_community($title,$default_values,$form_name);
305
}elseif(file_exists($ms_cfg_file)){
307
//$field_com=read_configuration($ms_cfg_file,$search,'ID');
308
if (is_array($field_com)){
310
msg_success($msg_ok);
311
$field_com=parse_xml_file($ms_cfg_file,$search,"COMMUNITY");
313
if (is_array($field_com) and $field_com != array()){
316
while ($field_com[$i]){
317
foreach ($field_com[$i] as $key=>$value){
318
$sql.= "'".$value. "' as ".$key.",";
319
$list_fields[$key]=$key;
321
$sql=substr($sql,0,-1)." union select ";
324
$sql=substr($sql,0,-13);
325
$list_fields['MODIF']='ID';
326
$list_fields['SUP']='ID';
327
$default_fields=array('NAME'=>'NAME','MODIF'=>'MODIF','SUP'=>'SUP');
328
$list_col_cant_del=$default_fields;
329
$tab_options['LBL_POPUP']['SUP']='NAME';
330
$tab_options['NO_NAME']['NAME']=1;
331
$result_exist=tab_req($table_name,$list_fields,$default_fields,$list_col_cant_del,$sql,$form_name,80,$tab_options);
246
$sql="select * from snmp_communities";
247
$list_fields= array('VERSION' => 'VERSION',
249
'USERNAME'=>'USERNAME',
250
'AUTHKEY'=>'AUTHKEY',
251
'AUTHPASSWD'=>'AUTHPASSWD',
254
//$list_fields['SUP']='ID';
255
$default_fields=$list_fields;
256
$list_col_cant_del=$list_fields;
257
$tab_options['LBL_POPUP']['SUP']='NAME';
258
$tab_options['LBL']['SUP']=$l->g(122);
259
$result_exist=tab_req($table_name,$list_fields,$default_fields,$list_col_cant_del,$sql,$form_name,80,$tab_options);
335
262
echo "<input type = submit value='".$l->g(116)."' name='ADD_COMM'>";
337
263
$protectedPost['ADD_COMM'] = $l->g(116);