[SOLVED]: Call File Unintentionally Repeating

Greetings,
I am running Asterisk 1.4.30-rc3, using DAHDI Complete 2.2.1+2.2.1 and LibPRI 1.4.10.2 on a CentOS 5.4 box. I have a Cyber Data VoIP Paging Gateway connected to the system which is then connected to a Bogen paging system. I have Asterisk configured to grab a call the paging extension, sound a tone, wait for key presses, then records the key presses, then sounds another tone and begins recording the user’s page, then the user hangs up and the call file is activated which calls the gateway, plays back the key presses for the paging zone, then plays back the user’s message twice, then hangs up. Everything seems to work fine, except I keep getting these “phantom pages”. Sometimes pages don’t go through until an hour or so later, and sometimes, old pages are repeated. Any thoughts? Here are the configs:

SIP.conf
;Paging*****
[x949]
; Paging
type=friend
host=dynamic
secret=bigSecret
context=users
qualify=no

EXTENSIONS.conf
[users]
;Repeat Paging******
exten => 445,1,Answer()
exten => 445,n,Wait(2.5)
exten => 445,n,SendDTMF(${ttone})
exten => 445,n,Wait(1.5)
exten => 445,n,Playback(/var/lib/asterisk/sounds/custom/page)
exten => 445,n,Wait(0.5)
exten => 445,n,Playback(beep)
exten => 445,n,Wait(0.5)
exten => 445,n,Playback(/var/lib/asterisk/sounds/custom/page)
exten => 445,n,Wait(1)

[newpage]
exten => s,1,Answer()
exten => s,n,Wait(0.5)
exten => s,n,Playback(beep)
exten => s,n,Read(digito,2)
exten => s,n,Set(GLOBAL(ttone)=${digito})
exten => s,n,Wait(1)
exten => s,n,Record(/var/lib/asterisk/sounds/custom/page:gsm|5|60|x)
exten => s,n,Wait(0.5)
exten => h,1,System(cp /tmp/page.call.save /tmp/page.call)
exten => h,n,System(mv /tmp/page.call /var/spool/asterisk/outgoing/)
exten => h,n,Hangup()

exten => i,1,Hangup()

exten => t,1,Hangup()

exten => 445,n,Hangup()

;*********Paging System
[paging]
;### Repeat paging
exten => 949,1,Goto(newpage,s,1)
exten => 949,n,Playtones(busy)
exten => 949,n,Busy()
exten => 949,n,Hangup()

page.call.save

Channel: SIP/x949
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Archive: yes
Context: users
Extension: 445

SOLVED*

In case anyone else has a similar issue, here’s how I solved it:

[newpage]
exten => s,1,Answer()
exten => s,n,Set(GLOBAL(complete)=“NO”)
exten => s,n,Wait(0.5)
exten => s,n,Playback(beep)
exten => s,n,Read(digito,2)
exten => s,n,Set(GLOBAL(ttone)=${digito})
exten => s,n,Wait(1)
exten => s,n,Set(GLOBAL(complete)=“YES”)
exten => s,n,Record(/var/lib/asterisk/sounds/custom/page:gsm|5|60|x)
exten => s,n,Wait(0.5)

exten => h,1,GotoIf($["${complete}" = “YES”]?page1:page2)
exten => h,n(page1),System(cp /tmp/page.call.save /tmp/page.call)
exten => h,n,System(mv /tmp/page.call /var/spool/asterisk/outgoing/)
exten => h,n,Hangup()
exten => h,n(page2),Hangup()

exten => i,1,Hangup()

exten => t,1,Hangup()

What was happening was the old pages would repeat if someone dialed the paging extension, and then hung up before entering any zone digits. It caused the program to copy the call file into the spool again and it would play the last message recorded to the page sound file.