Zphone chese.php: Unterschied zwischen den Versionen

Aus metasec wiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „=Chese Durchburg über Leistungsmerkmale= Rückgabe: ${ZCHESE} 0 oder 1 kann später über gotoif ausgewertet werden: <pre> [macro-anruf] exten => s, 1, TrySy…“)
(kein Unterschied)

Version vom 29. Oktober 2009, 11:51 Uhr

Chese Durchburg über Leistungsmerkmale

Rückgabe:

${ZCHESE} 0 oder 1

kann später über gotoif ausgewertet werden:

[macro-anruf]
exten => s, 1, TrySystem(/usr/local/metasec/bin/zphone_msg.sh ${ARG1} ${CALLERID(num)} i ${CHANNEL} ${UNIQUEID})
exten => s, 2, Agi(zphone_chese.php,${CALLERID(num)},${ARG1})
exten => s, 3, Set(__ZCHESE=${ZCHESE})
exten => s, 4, GoToIf($["${ZCHESE}"="1"]?10)
exten => s, 5, Set(UML=${DB(uml_target/${ARG1})})
exten => s, 6, Set(DND=${DB(dnd/${ARG1})})
exten => s, 7, GoToIf($["${DND}"="1"]?100)
exten => s, 8, NoOp(${UML})
exten => s, 9, GoToIf($[${LEN(${UML})}>0]?300)
exten => s, 10, Agi(zphone_grp_count.php,${ARG1})
exten => s, 11, Set(GROUPCOUNT=${GROUP_COUNT(${ARG1})})
exten => s, 12, NoOp(${GROUPCOUNT})
exten => s, 13, GoToIf($[${CHAN_COUNT}>1]?100)
exten => s, 14, Dial(SIP/${ARG1},${ARG2},tro)
exten => s, 15, TrySystem(/usr/local/metasec/bin/zphone_msg.sh ${ARG1} ${MACRO_EXTEN} m ${CHANNEL} ${UNIQUEID} upd)
exten => s, 16, GoToIf($["${ARG2}">"0"]?100)
exten => s, 17, Hangup()
exten => s, 100, GoToIf($[${LEN(${CALLERID(num)})}=2]?200)
exten => s, 101, GoToIfTime(7:30-17:30|mon-thu|*|*?400)
exten => s, 102, GoToIfTime(7:30-12:00|fri|*|*?400)
exten => s, 103, Answer()
exten => s, 104, Playback(/var/www/zphone/sounds/nachtschaltung)
exten => s, 105, Hangup()
exten => s, 200, Busy(30)
exten => s, 201, Hangup()
exten => s, 300, Dial(Local/${UML}@default)
exten => s, 301, Hangup()
exten => s, 400, Answer()
exten => s, 401, Dial(Local/98@default,,trom(WTT))
exten => s, 402, Hangup()

Code

#!/usr/bin/php4 -q
<?php
/*
 *      Script for DND breaktroutgh
 *      Lukas Ziaja <lz@metasec.de>
 *      METASEC
 *
*/

$in = fopen("php://stdin", "r");

/*
 *      clear up the params
 */

foreach ( $argv as $key => $val ) {
    $argv[$key] = trim($val);
}


/*
 *      we need at least two params
*/
if ( $argv[1] == "" && $argv[2] == "" ) {
    echo "set variable ZCHESE 0\n";
    fclose($in);
    return true;
}



/*
 *      include some essential stuff
 */
include_once("/var/www/zphone/etc/config.inc.php");
include($CCBOX["INC"]."func_sql.inc.php");

/*
 *      output some stuff...
 */
echo "noop zphone_chese script params: 1: ".$argv[1]." 2: ".$argv[2]."\n";


$s = new SQL;
$ZCHESE = 0;

/*
 *      lookup global settingtable
 */

$s->query("SELECT pf_val FROM pbx_features WHERE pf_key='pbx_chesi_anrufer' ");
$s->next_record();
$ZCHESE = trim($s->f("pf_val"));
$s->free_result();
if ( $ZCHESE == 0 || empty($ZCHESE) ) {

    echo "set variable ZCHESE 0\n";
    fclose($in);
    return true;

} elseif ( in_array($argv[1], explode(",", $ZCHESE ) ) ) {

    echo "noop access granted based on global\n";
    echo "set variable ZCHESE 1\n";
    fclose($in);
    return true;

}

/*
 *      lookup user settingtable
 */
$ZCHESE = 0;
$s->query("select pfu_val from pbx_features_user as a left join ast_users as b on a.pfu_ae_id=b.ae_id and b.ae_ext=".$argv[2]." where a.pfu_key='pbx_chesi_anrufer'");
$s->next_record();
$ZCHESE = trim($s->f("pfu_val"));
$s->free_result();
if ( $ZCHESE == 0 || empty($ZCHESE) ) {

    echo "set variable ZCHESE 0\n";
    fclose($in);
    return true;

} elseif ( in_array($argv[1], explode(",", $ZCHESE ) ) ) {

    echo "noop access granted based on local\n";
    echo "set variable ZCHESE 1\n";
    fclose($in);
    return true;

}

echo "set variable ZCHESE 0\n";
fclose($in);
return true;


?>