File: external_script.php

package info (click to toggle)
kalkun 0.8.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,340 kB
  • sloc: php: 30,659; javascript: 30,443; sql: 961; sh: 766; xml: 105; makefile: 41
file content (58 lines) | stat: -rw-r--r-- 2,046 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

// phpcs:disable CodeIgniter.Commenting.InlineComment.WrongStyle
/*
|--------------------------------------------------------------------------
| CONFIGURATION
|--------------------------------------------------------------------------
|
| Execute external script if condition match
|
| intepreter_path - path to the script interpreter (bash, python...), not path to script
| script_path - path to the script to be executed
| key - what condition we look at <sender|content>
| type - matching pattern used <equal|contain|preg_match>
| value - the value to match with
| parameter - extra parameter to send to the script <phone|content|id|time|match>,
|             each value separated by |
|
*/
// phpcs:enable

// Below are some examples
// Enable one or more scripts by uncommenting `array_push($config['external_script'], $script);`

$config['external_script'] = array();

$script = array();
$script['intepreter_path'] = '/bin/sh';
$script['script_path'] = '/usr/local/reboot_server.sh';
$script['key'] = 'content';
$script['type'] = 'equal';
$script['value'] = 'reboot';
$script['parameter'] = 'phone|id|content';
//array_push($config['external_script'], $script);
unset($script);

$script = array();
$script['intepreter_path'] = '/bin/sh';
$script['script_path'] = '/usr/local/check_user.sh';
$script['key'] = 'sender';
$script['type'] = 'contain';
$script['value'] = '+62';
$script['parameter'] = 'phone|content';
//array_push($config['external_script'], $script);
unset($script);

$script = array();
$script['intepreter_path'] = '/usr/bin/python3';
$script['script_path'] = '/opt/kinetools/scripts/timing_rappel.py';
$script['key'] = 'content';
$script['type'] = 'preg_match';
// for example, message: "ACTIVER rappel 10" will match the pattern below
// and the parameter match will have a value of "10"
$script['value'] = '/\s*ACTIVER\s+rappel\s+([0-9]+)\s*/i';
$script['parameter'] = 'phone|match';
//array_push($config['external_script'], $script);
unset($script);