root/modules/branches/2.10/core/agi-bin/list-item-remove.php

Revision 7630, 2.0 kB (checked in by mickecarlsson, 4 years ago)

Closes #3492, add license text to carios files and directories in core

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/bin/php -q
2 <?php
3 //This file is part of FreePBX.
4 //
5 //    FreePBX is free software: you can redistribute it and/or modify
6 //    it under the terms of the GNU General Public License as published by
7 //    the Free Software Foundation, either version 2 of the License, or
8 //    (at your option) any later version.
9 //
10 //    FreePBX is distributed in the hope that it will be useful,
11 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //    GNU General Public License for more details.
14 //
15 //    You should have received a copy of the GNU General Public License
16 //    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>.
17 //
18 //    Copyright 2007 Philippe Lindheimer
19
20 /*
21 Removes an item from a character delimited list.
22
23 Usage: list-item-remove.php list item varname [listseparator]
24
25 list: The list of strings separated by a character (example: 1&2&3)
26 item: The value of the item to remove
27 varname: The variable to return the new list in
28 listseparator: The separator.  This defaults to "&" if it is not specified.
29 */
30
31 /* --------WARNING---------
32  *
33  * This script is auto-copied from an included module and will get overwritten.
34  * If you modify it, you must change it to write only, in the agi-bin directory,
35  * to keep it from getting changed.
36  */
37
38 include("phpagi.php");
39
40 $agi = new AGI;
41
42 if (!isset($argv[1])) {
43         $agi->verbose("Missing list");
44         exit(1);
45 }
46
47 if (!isset($argv[2])) {
48         $agi->verbose("Missing item");
49         exit(1);
50 }
51
52 if (!isset($argv[3])) {
53         $agi->verbose("Missing return var name");
54         exit(1);
55 }
56
57 $arglist = $argv[1];
58 $argitem = $argv[2];
59 $argvarname = $argv[3];
60
61 if (isset($argv[4])) {
62         $argsep = "&";
63 } else {
64         $argsep = $argv[4];
65 }
66
67 $newlist = str_replace($argitem.$argsep, "", $arglist.$argsep);
68
69 if (substr($newlist, -1, 1) == $argsep) {
70         $newlist = substr($newlist, 0, -1);
71 }
72
73 $agi->set_variable($argvarname, $newlist);
74 ?>
75
Note: See TracBrowser for help on using the browser.