[solved] agi asterisk 1.6

Hi all,
I’ve updated asterisk to version 1.6.0.1
Before the upgrade AGI script works well.
Now AGI script doesn’t work!

This is the scritp:

#!/usr/bin/php -q

<?php
        require_once ('../phpagi.php');
        require_once ('../phpagi-asmanager.php');
        require_once ('connessione_cc.php');
        set_time_limit('3600');

        ob_implicit_flush(true);

        $festivo="FALSE";

        mysql_select_db("calendario");
        $oggi=date("Y-m-d");
        $query = "SELECT * FROM giorni_speciali_gruppi WHERE giorno='".$oggi."'";
        $result = mysql_query($query) or die ("ERRORE NELLA QUERY DI RICERCA DELLO STATO: ".mysql_error());
        $rows = mysql_num_rows($result);

        if ($rows=="0") $stato="chiuso";
        else {
                $festivo="TRUE";
                $stato="chiuso";
                while ($rs = mysql_fetch_array($result)){
                        $today = date("H:i:s");
                        if( ($today>=$rs['inizio1'] AND $today<=$rs['fine1']) OR ($today>=$rs['inizio2'] AND $today<=$rs['fine2']) ){
                                $stato="aperto";
                                break;
                        }//if
                }//while
        }//else

        if ($festivo=="FALSE"){

                $giorno_sett=date("w");
                $query="SELECT * FROM planning_120 ";
                if ($giorno_sett=="0") $query.="WHERE giorno='DOM'";
                if ($giorno_sett=="1") $query.="WHERE giorno='LUN'";
                if ($giorno_sett=="2") $query.="WHERE giorno='MAR'";
                if ($giorno_sett=="3") $query.="WHERE giorno='MER'";
                if ($giorno_sett=="4") $query.="WHERE giorno='GIO'";
                if ($giorno_sett=="5") $query.="WHERE giorno='VEN'";
                if ($giorno_sett=="6") $query.="WHERE giorno='SAB'";

                $result = mysql_query($query) or die ("ERRORE NELLA QUERY DI RICERCA DELLO STATO: ".mysql_error());
                $stato="chiuso";
                $today = date("H:i:s");

                while ($rs = mysql_fetch_array($result)){
                        if( ($today>=$rs['inizio1'] AND $today<=$rs['fine1']) OR ($today>=$rs['inizio2'] AND $today<=$rs['fine2']) ){
                                $stato="aperto";
                                break;
                        }//if
                }//while

        }//if

        $agi = new AGI();
        $agi->answer();

        $agi->set_variable("stato_120",$stato);
?>

CLI:

Connected to Asterisk 1.6.0.1 currently running on comip (pid = 2594)
Verbosity was 4 and is now 5
  == Using SIP RTP CoS mark 5
    -- Executing [120@interni:1] AGI("SIP/145-09477528", "itermar/gruppo120.php") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/itermar/gruppo120.php
<SIP/145-09477528>AGI Tx >> agi_request: itermar/gruppo120.php
<SIP/145-09477528>AGI Tx >> agi_channel: SIP/145-09477528
<SIP/145-09477528>AGI Tx >> agi_language: it
<SIP/145-09477528>AGI Tx >> agi_type: SIP
<SIP/145-09477528>AGI Tx >> agi_uniqueid: 1228153252.22
<SIP/145-09477528>AGI Tx >> agi_version: 1.6.0.1
<SIP/145-09477528>AGI Tx >> agi_callerid: 145
<SIP/145-09477528>AGI Tx >> agi_calleridname: 145
<SIP/145-09477528>AGI Tx >> agi_callingpres: 0
<SIP/145-09477528>AGI Tx >> agi_callingani2: 0
<SIP/145-09477528>AGI Tx >> agi_callington: 0
<SIP/145-09477528>AGI Tx >> agi_callingtns: 0
<SIP/145-09477528>AGI Tx >> agi_dnid: 120
<SIP/145-09477528>AGI Tx >> agi_rdnis: unknown
<SIP/145-09477528>AGI Tx >> agi_context: interni
<SIP/145-09477528>AGI Tx >> agi_extension: 120
<SIP/145-09477528>AGI Tx >> agi_priority: 1
<SIP/145-09477528>AGI Tx >> agi_enhanced: 0.0
<SIP/145-09477528>AGI Tx >> agi_accountcode:
<SIP/145-09477528>AGI Tx >> agi_threadid: -1213322320
<SIP/145-09477528>AGI Tx >>
<SIP/145-09477528>AGI Rx << Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<        php <file> [args...]
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -a               Run interactively
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -C               Do not chdir to the script's directory
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -c <path>|<file> Look for php.ini file in this directory
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -n               No php.ini file will be used
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -d foo[=bar]     Define INI entry foo with value 'bar'
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -e               Generate extended information for debugger/profiler
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -f <file>        Parse <file>.  Implies `-q'
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -h               This help
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -i               PHP information
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -l               Syntax check only (lint)
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -m               Show compiled in modules
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -q               Quiet-mode.  Suppress HTTP Header output.
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -s               Display colour syntax highlighted source.
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -v               Version number
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -w               Display source with stripped comments and whitespace.
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
<SIP/145-09477528>AGI Rx <<   -z <file>        Load Zend extension <file>.
<SIP/145-09477528>AGI Tx >> 510 Invalid or unknown command
    -- <SIP/145-09477528>AGI Script itermar/gruppo120.php completed, returning 0

Someone can help me?

anyone can help me?

Hi

The best advice is to revert back to the last known good version, then read ALL the release notes for 1.6 . there are many changes including the manager interface. and then build a test server with the script and go through the errors one at a time. 1.4 to 1.6 is a BIG jump there are many changes

Ian

I’m sorry, this issue is caused by special characters (LF, CR) in php script.
AGI work very well in * 1.6!