function Aastra_change_vm_password($user, $password) { global $ASTERISK_LOCATION; global $AA_VM_CONTEXT; # False by default $return = False; # Read the file $lines = @file($ASTERISK_LOCATION . 'voicemail.conf'); $section = NULL; $dump = True; foreach ($lines as $line) { $line = rtrim($line); if (preg_match("/^\\s*\\[([a-z]*)\\]\\s*\$/i", $line, $m)) { $section = $m[1]; } if ($section == $AA_VM_CONTEXT && preg_match("/^([0-9]*)\\s*=>?\\s*([0-9]*)\\s*,(.*)\$/", $line, $m)) { if ($m[1] == $user) { $dump = False; $output[] = $m[1] . ' => ' . $password . ',' . $m[3]; $return = True; } } if ($dump) { $output[] = $line; } else { $dump = True; } } # Rewrite the file if ($return) { if ($fd = fopen($ASTERISK_LOCATION . 'voicemail.conf', 'w')) { fwrite($fd, implode("\n", $output) . "\n"); fclose($fd); } else { $return = False; } } # Reload the VM if ($return) { # Reload VM configuration $as = new AGI_AsteriskManager(); $res = $as->connect(); $as->Reload('app_voicemail'); $as->disconnect(); } # Return result return $return; }