authenticate external and internal users/reminders

Discussion in 'General' started by franklin, Feb 26, 2011.

  1. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    I added the 4th step here and it broke the authentication for Reminders. I want to be able to have internal users auth by their VM, as in step 3, and let outside users auth by a simple password, as in step 4. I see on my tail that it uses the caller ID of my cell as a user: VERBOSE[20887] logger.c: -- Incorrect password '1234' for user '1xxxxxxxxxx' (context = default)

    Is there a way to use both methods to auth Reminders?

    [from-internal-custom]
    exten => 123,1,Answer
    exten => 123,2,Wait(1)
    exten => 123,3,vmauthenticate(${CALLERID(number)})
    exten => 123,4,Authenticate(1234)
    exten => 123,5,Goto(reminder,s,1)
     
  2. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
  3. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    I'd like to start out with a simple password file. Authenticate(/passwdfile|[,options[,maxdigits]])

    in /etc I did vi reminderspasswords
    and put 4 lines of 4-digit passwords and saved
    then did what you see below and amportal restart. I don't seem to be hitting the password file. Where should that be kept? I see passwd in /etc, but it doesn't seem like adding to that is a good idea.


    [from-internal-custom]
    exten => 123,1,Answer
    exten => 123,2,Wait(1)
    ;exten => 123,3,vmauthenticate(${CALLERID(number)})
    exten => 123,3,Authenticate(/reminderspasswords)
    exten => 123,4,Goto(reminder,s,1)

    Thank you.
     
  4. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    The asterisk home directory is /var/lib/asterisk
     
  5. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    little lost. I put a file in /var/lib/asterisk called passwords and changed ownership to asterisk asterisk. Put a single line of 1234. Called that file out in extensions_custom.conf

    [from-internal-custom]
    exten => 123,1,Answer
    exten => 123,2,Wait(1)
    ;exten => 123,3,vmauthenticate(${CALLERID(number)})
    exten => 123,3,Authenticate(/passwords)
    exten => 123,4,Goto(reminder,s,1)

    Still doesn't work. Spent a lot of time going over all the links at http://www.voip-info.org/wiki/view/Aste ... thenticate

    I assume that Authenticate(/<filename>) would look up whatever is in "filename." What am I doing wrong? Tried twice to reg to the pbxinaflash forum. Their mod does not authenticate you. ???

    Thanks.
     
  6. fmvillares

    Joined:
    Sep 8, 2007
    Messages:
    1,785
    Likes Received:
    0
    sorry guys the authentication files for pin sets ned to be saved in etc/asterisk...
     
  7. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    fm, dicko,

    I put a file in /etc/asterisk/ called passwords. It has asterisk:asterisk ownership

    dialing 123 hangs up when I have exten => 123,3,Authenticate(/passwords) or exten => 123,3,Authenticate/passwords

    I put a file in /etc/asterisk/ called passwords. It has asterisk:asterisk ownership

    dialing 123 hangs up when I have exten => 123,3,Authenticate(/passwords) or exten => 123,3,Authenticate/passwords

    [from-internal-custom]
    exten => 123,1,Answer
    exten => 123,2,Wait(1)
    ;exten => 123,3,vmauthenticate(${CALLERID(number)})
    exten => 123,3,Authenticate(/passwords)
    exten => 123,4,Goto(reminder,s,1)

    I want the Authenticate to take a password from a file. Any help? Thanks.
     
  8. fmvillares

    Joined:
    Sep 8, 2007
    Messages:
    1,785
    Likes Received:
    0
    Re: Re:authenticate external and internal users/reminders

    i have my passwords files in /tc/asterisk named pins and works perfect
    exten=> 123,1,Authenticate(pins)
     
  9. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    Re: Re:authenticate external and internal users/reminders

    in /etc/asterisk/
    -rw-rw-r-- 1 asterisk asterisk 15 Mar 4 16:25 passwords
    inside passwords
    1234
    5678
    9876
    in extensions_custom.conf
    [from-internal-custom]
    ;exten => 123,1,Answer
    ;exten => 123,2,Wait(1)
    ;exten => 123,3,vmauthenticate(${CALLERID(number)})
    exten => 123,1,Authenticate(passwords)
    exten => 123,2,Goto(reminder,s,1)

    She answers but tells me my password is incorrect. I do an amportal restart after every change to extensions_custom.conf

    ?
     
  10. fmvillares

    Joined:
    Sep 8, 2007
    Messages:
    1,785
    Likes Received:
    0
    Re: Re:authenticate external and internal users/reminders

    http://www.voip-info.org/wiki/view/Aste ... thenticate

    i was having a long time ago a bug in asterisk # as send key for this type of apps...1.4.33 i think...and it was repetead in 1.6.2.17 as of today...the solution was to wait after the enter of the password without pressing # and worked...
     
  11. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    Still doesn't work. I am running 1.6. FreePBX updated to 2.7.

    I put a new pswd file in etc/asterisk called pins. Put 1234 on the first line. That's it.

    Have tried pins with as (/pins) and (pins) and did an amportal restart after every change. She tells me password incorrect every time. If I put (1234) after Authenticate it works. Tried not pressing #, too. Doesn't work. Am I putting the pswd file in the right place -- /etc/asterisk I get this on a tail:

    WARNING[4187] app_authenticate.c: Unable to open file '/pins' for authentication: No such file or directory
    [Mar 5 12:40:12] VERBOSE[4187] logger.c: -- <SIP/3960-00000001> Playing 'auth-incorrect' (language 'en')
    [Mar 5 12:40:21] WARNING[4187] file.c: Failed to write frame


    Thanks.

    [from-internal-custom]
    ;exten => 123,1,Answer
    ;exten => 123,2,Wait(1)
    ;exten => 123,3,vmauthenticate(${CALLERID(number)})
    exten => 123,1,Authenticate(pins)
    exten => 123,2,Goto(reminder,s,1)
     
  12. fmvillares

    Joined:
    Sep 8, 2007
    Messages:
    1,785
    Likes Received:
    0
    Re: Re:authenticate external and internal users/reminders

    and your dmtf modes both in the phone and in asterisk box?
     
  13. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    Re: Re:authenticate external and internal users/reminders

    DTMF modes are standard. rfc2833 on the Ext.
    Trunk:
    disallow=all
    type=friend
    trustrpid=yes
    dendrpid=yes
    host=xxx.xxx.xxx.xxx
    context=from-trunk
    canreinvite=no
    insecure=port,invite
    allow=ulaw
    qualify=yes

    Going to try adding dtmfmode=inband to Trunk. Had to do this with ohter 1.6 boxes to make remote IVR access work. But not on this box. Strange.
     
  14. fmvillares

    Joined:
    Sep 8, 2007
    Messages:
    1,785
    Likes Received:
    0
    Re: Re:authenticate external and internal users/reminders

    with inband no asterisk tones or apps work...watch that !
     
  15. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    dicko, fm,
    Sorry for the length of this post. Any advice on how to fix this time stamping issue? Thank you:
    Scenario: At 3:13PM I dial 123, plus code. Get into Reminders. Record the message. Enter the date. And accept. (I am on 24-hour format) The only way I can get it to accept the hour is if I enter 1:05 past the current time. I enter 16:20 and it returns back “you entered 3:20PM. Is this correct?” I accept and schedule
    Then, the file that logs each call -- /var/log/asterisk/reminder.txt -- time stamps itself at the top with the correct date but the time of “16:13:42 ***New session ***” This date and time is specified in reminder.php as full form“….ll Rights Reserved.\n\n" . date("F j, Y - H:i:s"),..”
    Reminder.txt also shows APPTTIME: 1620
    var/spool/asterisk/outgoing also lists it as Mar 19 2011 1620.20110319.<phonenumber>.call

    But the call gets placed at 3:20P/15:20. (same thing happens with the Web interface, which I was able to secure by editing /etc/httpd/conf/httpd.conf – thanks to PS paid support)
    I’ve been looking at the code on reminder.php and everything else I can find from a # locate reminder. I can’t figure out why "F j, Y - H:i:s is returning an hour ahead, and why all the calls show the wrong time, but get delivered at the right time. Been Googling and learning PHP. Stuck.
    # date returns Sat Mar 19 15:33:54 MST 2011, so the time, relatively speaking, that Allison read back to me.
    # /etc/sysconfig/clock returns:
    UTC=false
    ARC=false
    ZONE="America/Phoenix"
    The script in crontab and the routine at /var/lib/asterisk/agi-bin/run_reminders don’t seem to affect the time stamp. Seems it is in /var/lib/asterisk/agi-bin/reminder (contents which I have not posted)
    crontab:
    00 0 * * * root /var/lib/asterisk/agi-bin/run_recurring
    03 0 * * * root /var/lib/asterisk/agi-bin/run_reminders


    run_reminders :
    #!/usr/bin/perl

    $PENDING = "/var/spool/asterisk/reminders" ;
    $OUTGOING = "/var/spool/asterisk/outgoing" ;
    $SLEEP = 5 ;

    chomp($DATE = `/bin/date +%Y%m%d`);

    chdir($PENDING) ;

    foreach $file ( <*.$DATE.*.call> )
    {
    if ( -r $file )
    {
    $file =~ m/^(\d\d\d\d)\.(\d\d\d\d\d\d\d\d)\..+\.call$/ ;
    $timestamp = $2 . $1 ;
    rename($file, "$OUTGOING/$file") ;
    system("touch -t $timestamp $OUTGOING/$file") ;
    sleep($SLEEP) ;
     
  16. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Arizona doesn't do daylight saving, I would check your TimeZone data to make sure it knows. Or perhaps pragmatically ,maybe use a time zone for the next eight months that matches your time but isn't so quirky :) . Perhaps change your php.ini to suit also?
     
  17. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    I know. #date shows I am on MST. And # /etc/sysconfig/clock returns:
    UTC=false
    ARC=false
    ZONE="America/Phoenix"

    So I have to assume I am not on dls. I searched all over and there is no setting for it. This is a fresh load and I recall picking Phoenix as the time zone, so my server knows I am not on dls. For some reason Reminders doesn't. It's a lot to dig into, I know. You told me I was going to have to get my hands dirty. Been studying PHP all day. If you are so inclined, here is the reminder.php file... Thanks.

    #!/usr/bin/php -q
    <?
    ob_implicit_flush(false);
    error_reporting(0);
    set_time_limit(300);

    // Telephone Reminders ver. 4.0.1, (c) Copyright 2006-2008, Ward Mundy. All rights reserved.

    //-------- DON'T CHANGE ANYTHING ABOVE THIS LINE ----------------

    $endofmonthflag=1;
    $extensionmaxdigits=4 ;
    $debug = 1;
    $newlogeachdebug = 1;
    $emaildebuglog = 1;
    $email = "cory@securecloudsolutions.com" ;
    $trunk = "local" ;
    $callerid = "6781234567" ;
    $numcallattempts=6 ;
    $calldelaybetweenruns=300 ;
    $timetoring=40 ;
    $acctcode= "Reminder" ;

    //-------- DON'T CHANGE ANYTHING BELOW THIS LINE ----------------

    $log = "/var/log/asterisk/reminder.txt" ;
    if ($debug and $newlogeachdebug) :
    if (file_exists($log)) :
    unlink($log) ;
    endif ;
    endif ;

    $stdlog = fopen($log, 'a');
    $stdin = fopen('php://stdin', 'r');
    $stdout = fopen( 'php://stdout', 'w' );

    if ($debug) :
    fputs($stdlog, "Telephone Reminders 4.0.1 (c) Copyright 2006-2008, Ward Mundy. All Rights Reserved.\n\n" . date("F j, Y - H:i:s") . " *** New session ***\n\n" );
    endif ;

    function read() {
    global $stdin;
    $input = str_replace("\n", "", fgets($stdin, 4096));
    dlog("read: $input\n");
    return $input;
    }

    function write($line) {
    dlog("write: $line\n");
    echo $line."\n";
    }

    function dlog($line) {
    global $debug, $stdlog;

    if ($debug) fputs($stdlog, $line);
    }

    function execute_agi( $command )
    {
    GLOBAL $stdin, $stdout, $stdlog, $debug;

    fputs( $stdout, $command . "\n" );
    fflush( $stdout );
    if ($debug)
    fputs( $stdlog, $command . "\n" );

    $resp = fgets( $stdin, 4096 );

    if ($debug)
    fputs( $stdlog, $resp );

    if ( preg_match("/^([0-9]{1,3}) (.*)/", $resp, $matches) )
    {
    if (preg_match('/result=([-0-9a-zA-Z]*)(.*)/', $matches[2], $match))
    {
    $arr['code'] = $matches[1];
    $arr['result'] = $match[1];
    if (isset($match[3]) && $match[3])
    $arr['data'] = $match[3];
    return $arr;
    }
    else
    {
    if ($debug)
    fputs( $stdlog, "Couldn't figure out returned string, Returning code=$matches[1] result=0\n" );
    $arr['code'] = $matches[1];
    $arr['result'] = 0;
    return $arr;
    }
    }
    else
    {
    if ($debug)
    fputs( $stdlog, "Could not process string, Returning -1\n" );
    $arr['code'] = -1;
    $arr['result'] = -1;
    return $arr;
    }
    }

    // ------ Code execution begins here
    // parse agi headers into array
    while ($env=read()) {
    $s = split(": ",$env);
    $agi[str_replace("agi_","",$s[0])] = trim($s[1]);
    if (($env == "") || ($env == "\n")) {

    break;
    }
    }

    // $tmp = $agi['dnid'] ;

    if ($debug) :
    fputs($stdlog, "The following application-specific variables also were passed from Asterisk: \n" );
    endif ;


    $ThisApp = $_SERVER["argv"][0];
    $ThisApp = trim($ThisApp);
    //$parts = split("@",$vmbox);

    if ($debug) :
    fputs($stdlog, "ThisApp: " . $ThisApp . "\n" );
    endif ;

    // This tells us the APPTDT for the reminder call to be placed
    $APPTDT = $_SERVER["argv"][1];
    $APPTDT = trim($APPTDT);
    $APPTDT = ltrim($APPTDT);

    if ($debug) :
    fputs($stdlog, "APPTDT: " . $APPTDT . "\n" );
    endif ;

    // This tells us the APPTTIME for the reminder call to be placed
    $APPTTIME = $_SERVER["argv"][2];
    $APPTTIME = trim($APPTTIME);
    $APPTTIME = ltrim($APPTTIME);

    if ($debug) :
    fputs($stdlog, "APPTTIME: " . $APPTTIME . "\n" );
    endif ;

    // This tells us the APPTPHONE for the reminder call to be placed
    $APPTPHONE = $_SERVER["argv"][3];
    $APPTPHONE = trim($APPTPHONE);
    $APPTPHONE = ltrim($APPTPHONE);

    if ($debug) :
    fputs($stdlog, "APPTPHONE: " . $APPTPHONE . "\n" );
    endif ;

    // This tells us the recurring option selected for this reminder. We'll translate it into English below.
    $APPTRECUR = $_SERVER["argv"][4];
    $APPTRECUR = trim($APPTRECUR);
    $APPTRECUR = ltrim($APPTRECUR);

    // If scheduled on last day of the month, check the $endofmonthflag to determine if we always want reminders sent on last day of the month rather than actual day scheduled.

    $APPTYR = substr($APPTDT,0,4);
    $APPTMO = substr($APPTDT,4,2);
    $APPTDA = substr($APPTDT,6,2);
    if (date ("m", mktime (0,0,0,$APPTMO,$APPTDA,$APPTYR))<>date ("m", mktime (0,0,0,$APPTMO,$APPTDA+1,$APPTYR)) and $endofmonthflag) :
    $APPTDA = "31" ;
    endif ;

    if ($APPTRECUR=="2") :
    $RECURRING="weekday" ;
    if (date ("D", mktime (0,0,0,$APPTMO,$APPTDA,$APPTYR))=="Fri") :
    $NEXTDT=date("Ymd", mktime (0,0,0,$APPTMO,$APPTDA+3,$APPTYR));
    elseif (date ("D", mktime (0,0,0,$APPTMO,$APPTDA,$APPTYR))=="Sat") :
    $NEXTDT=date("Ymd", mktime (0,0,0,$APPTMO,$APPTDA+2,$APPTYR));
    else :
    $NEXTDT=date("Ymd", mktime (0,0,0,$APPTMO,$APPTDA+1,$APPTYR));
    endif ;
    $recur_script = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".call." . $RECURRING ;
    $recur_msg = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".gsm" ;
    elseif ($APPTRECUR=="3") :
    $RECURRING="daily" ;
    $NEXTDT=date("Ymd", mktime (0,0,0,$APPTMO,$APPTDA+1,$APPTYR));
    $recur_script = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".call." . $RECURRING ;
    $recur_msg = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".gsm" ;
    elseif ($APPTRECUR=="4") :
    $RECURRING="weekly" ;
    $NEXTDT=date("Ymd", mktime (0,0,0,$APPTMO,$APPTDA+7,$APPTYR));
    $recur_script = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".call." . $RECURRING ;
    $recur_msg = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".gsm" ;
    elseif ($APPTRECUR=="5") :
    $RECURRING="monthly" ;
    $NEXTDT=date("Ymd", mktime (0,0,0,$APPTMO+1,$APPTDA,$APPTYR));
    $NEXTYR = substr($NEXTDT,0,4);
    $NEXTMO = substr($NEXTDT,4,2);
    $NEXTDA = substr($NEXTDT,6,2);
    while (date ("m", mktime (0,0,0,$NEXTMO,$NEXTDA,$NEXTYR))<>date ("m", mktime (0,0,0,$APPTMO+1,1,$APPTYR))) :
    $NEXTDT=date("Ymd", mktime (0,0,0,$NEXTMO,$NEXTDA-1,$NEXTYR));
    $NEXTYR = substr($NEXTDT,0,4);
    $NEXTMO = substr($NEXTDT,4,2);
    $NEXTDA = substr($NEXTDT,6,2);
    endwhile ;
    $recur_script = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".call." . $RECURRING . $APPTDA ;
    $recur_msg = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".gsm" ;
    elseif ($APPTRECUR=="6") :
    $RECURRING="annually" ;
    $NEXTDT=date("Ymd", mktime (0,0,0,$APPTMO,$APPTDA,$APPTYR+1));
    $recur_script = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".call." . $RECURRING ;
    $recur_msg = "/var/spool/asterisk/recurring/" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . ".gsm" ;
    else :
    $RECURRING="once" ;
    $recur_script="once" ;
    endif ;
    if ($debug) :
    fputs($stdlog, "APPTRECUR: " . $APPTRECUR . "\n" );
    fputs($stdlog, "RECURRING: " . $recur_script . "\n" );
    endif ;


    $trunk = strtolower($trunk) ;
    $numcallattempts = $numcallattempts-1 ;

    $fromfile = "/tmp/reminder.tmp" ;
    if (date("Ymd") <> $APPTDT) :
    $tofile = "/var/spool/asterisk/reminders/" . $APPTTIME . "." . $APPTDT . "." . $APPTPHONE . ".call" ;
    else :
    $tofile = "/var/spool/asterisk/outgoing/" . $APPTTIME . "." . $APPTDT . "." . $APPTPHONE . ".call" ;
    endif ;
    $fptmp = fopen($fromfile, "w");
    if ($trunk<>"local") :
    if (strlen($APPTPHONE)<=$extensionmaxdigits) :
    $txt2write = "Channel: " . $trunk . "/" . $APPTPHONE . "@from-internal\n" ;
    else :
    $txt2write = "Channel: " . $trunk . "/" . $APPTPHONE . "\n" ;
    endif;
    else :
    if (strlen($APPTPHONE)<=$extensionmaxdigits) :
    $txt2write = "Channel: " . $trunk . "/" . $APPTPHONE . "@from-internal\n" ;
    else :
    $txt2write = "Channel: " . $trunk . "/" . $APPTPHONE . "@outbound-allroutes\n" ;
    endif ;
    endif;
    fwrite($fptmp,$txt2write) ;
    if ($trunk<>"local") :
    $txt2write = "Callerid: " . $callerid . "\n" ;
    fwrite($fptmp,$txt2write) ;
    else:
    $localid = chr(34)."Reminder".chr(34)." <123>" ;
    $txt2write = "Callerid: " . $localid . "\n" ;
    fwrite($fptmp,$txt2write) ;
    endif ;
    $txt2write = "MaxRetries: " . $numcallattempts . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "RetryTime: " . $calldelaybetweenruns . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "WaitTime: " . $timetoring . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Account: " . $acctcode . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "context: remindem\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "extension: s\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "priority: 1\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: MSG=" . $APPTTIME . "." . $APPTDT . "." . $APPTPHONE . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: APPTDT=" . $APPTDT . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: APPTTIME=" . $APPTTIME . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: APPTPHONE=" . $APPTPHONE . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: CALLATTEMPTS=" . $numcallattempts . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: CALLDELAY=" . $calldelaybetweenruns . "\n" ;
    fwrite($fptmp,$txt2write) ;
    fclose($fptmp) ;

    // set time stamp here to make .call file work at the correct time with Asterisk. Then move it.

    $time2call = mktime (substr($APPTTIME,0,2),substr($APPTTIME,2,2),5,substr($APPTDT,4,2),substr($APPTDT,6,2),substr($APPTDT,0,4)) ;
    touch($fromfile, $time2call);

    if ($RECURRING<>"once") :
    $frommsg = "/var/lib/asterisk/sounds/custom/" . $APPTTIME . "." . $APPTDT . "." . $APPTPHONE . ".gsm" ;
    copy ($frommsg,$recur_msg) ;
    endif;

    $moveok = rename($fromfile,$tofile) ;
    touch($tofile, $time2call);

    //Now we're ready to copy the reminder script (message file is copied above to avoid a problem if call is placed immediately) to recurring storage if one of those options was chosen.
    if ($RECURRING<>"once") :

    $fptmp = fopen($fromfile, "w");
    if ($trunk<>"local") :
    if (strlen($APPTPHONE)<=$extensionmaxdigits) :
    $txt2write = "Channel: " . $trunk . "/" . $APPTPHONE . "@from-internal\n" ;
    else :
    $txt2write = "Channel: " . $trunk . "/" . $APPTPHONE . "\n" ;
    endif;
    else :
    if (strlen($APPTPHONE)<=$extensionmaxdigits) :
    $txt2write = "Channel: " . $trunk . "/" . $APPTPHONE . "@from-internal\n" ;
    else :
    $txt2write = "Channel: " . $trunk . "/" . $APPTPHONE . "@outbound-allroutes\n" ;
    endif ;
    endif;
    fwrite($fptmp,$txt2write) ;
    if ($trunk<>"local") :
    $txt2write = "Callerid: " . $callerid . "\n" ;
    fwrite($fptmp,$txt2write) ;
    else:
    $localid = chr(34)."Reminder".chr(34)." <123>" ;

    $txt2write = "Callerid: " . $localid . "\n" ;
    fwrite($fptmp,$txt2write) ;
    endif ;
    $txt2write = "MaxRetries: " . $numcallattempts . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "RetryTime: " . $calldelaybetweenruns . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "WaitTime: " . $timetoring . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Account: " . $acctcode . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "context: remindem\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "extension: s\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "priority: 1\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: MSG=" . $APPTTIME . "." . $NEXTDT . "." . $APPTPHONE . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: APPTDT=" . $NEXTDT . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: APPTTIME=" . $APPTTIME . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: APPTPHONE=" . $APPTPHONE . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: CALLATTEMPTS=" . $numcallattempts . "\n" ;
    fwrite($fptmp,$txt2write) ;
    $txt2write = "Set: CALLDELAY=" . $calldelaybetweenruns . "\n" ;
    fwrite($fptmp,$txt2write) ;
    fclose($fptmp) ;

    $moveok = rename($fromfile,$recur_script) ;
    endif ;

    if ($debug) :
    fputs($stdlog, "Reminder saved to " . $tofile . " Date/Time: " . $APPTDT . "/" . $APPTTIME . " Phone#: " . $APPTPHONE . "\n" );
    fputs($stdlog, "\n\nNOTE: To delete this reminder prior to the actual date of the reminder, delete the above file.\n");
    fputs($stdlog, "To delete this reminder on the actual date of the reminder, delete the above file from /var/spool/asterisk/outgoing.\n");
    fputs($stdlog, "Also remember to delete the actual message sound file: /var/lib/asterisk/sounds/custom/" . $APPTTIME . "." . $APPTDT . "." . $APPTPHONE . ".gsm.\n\n");
    if ($RECURRING<>"once") :
    fputs($stdlog, "To delete the recurring reminder, delete the following files from /var/spool/asterisk/recurring:\n");
    fputs($stdlog, "$recur_script AND $recur_msg.\n");
    endif;
    endif ;


    if ($debug) :
    if ($emaildebuglog) :
    fputs($stdlog, "\n\nTelephone Reminders 4.0.1 session log emailed to " . $email . ".\n" );
    endif ;
    fputs($stdlog, "\n\n" . date("F j, Y - H:i:s") . " *** End of session ***\n\n\n" );
    endif ;

    if ($emaildebuglog) :
    system("mime-construct --to $email --subject " . chr(34) . "Telephone Reminders 4.0.1 Session Log" . chr(34) . " --attachment $log --type text/plain --file $log") ;
    endif ;


    // clean up file handlers etc.
    fclose($stdin);
    fclose($stdout);
    fclose($stdlog);
    exit;

    ?>
    ~
     
  18. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Although the OS understands your time zone, apparently php does not completely sorry don't no were the America/Phoenix in php is help

    http://www.php.net/manual/en/timezones.america.php

    maybe as I said over-ride your TimeZone in php.ini use MDT both in OS and php or move across state lines?

    as a hint I have always found it helps to have your hardware clock against UTC, unless of course Microsoft machines are involved :)
     
  19. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    That did it!!! /etc/php.ini
    ;;;;;;;;;;;;;;;;;;;
    ; Module Settings ;
    ;;;;;;;;;;;;;;;;;;;

    [Date]
    ; Defines the default timezone used by the date functions
    date.timezone = "America/Phoenix"

    The phone interface works properly. The Web interface works properly.

    /var/log/asterisk/checkdate.txt records the correct time stamp. It's all good!!

    To think that's what it was the whole time. I was in php.ini for a bit but did not figure it out. My studie$s helped imensely, though. I can now follow along and decipher, almost exactly, what the PHP scripts say, and I can follow the logical pattern of what goes on in a program much better. I really tried to figure this one out before I went to the teacher.

    On to bigger and better things. Love to love ya, "/". franklin
     
  20. franklin

    Joined:
    Oct 22, 2010
    Messages:
    254
    Likes Received:
    0
    http://www.linuxsa.org.au/tips/time.html
    shows
    "the preferred option is to keep it in UTC because then daylight savings can be automatically accounted for." As you say.
    But I never spring or fall. Nevertheless, the OS should know this, hopefully php.ini too, and time should never change. So it would be a good habit to do this?
    /etc/sysconfig/clock
    UTC=true
    ARC=false
    ZONE="America/Phoenix"

    Here is what I have:
    # hwclock
    Sat 19 Mar 2011 06:09:18 PM MST -0.153413 seconds
    # date
    Sat Mar 19 18:09:37 MST 2011
    PS did ln -sf /usr/share/zoneinfo/UTC /etc/localtime
    and
    cat /etc/localtime shows this:
    LMTMDTMSTMWT
    MST7
     

Share This Page