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

Revision 4291, 1.2 kB (checked in by p_lindheimer, 5 years ago)

#2041: fixlocalprefix had typo, also removed hardcoded paths in several agi scripts

  • 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
4 /*
5 Removes an item from a character delimited list.
6
7 Usage: list-item-remove.php list item varname [listseparator]
8
9 list: The list of strings separated by a character (example: 1&2&3)
10 item: The value of the item to remove
11 varname: The variable to return the new list in
12 listseparator: The separator.  This defaults to "&" if it is not specified.
13 */
14
15 /* --------WARNING---------
16  *
17  * This script is auto-copied from an included module and will get overwritten.
18  * If you modify it, you must change it to write only, in the agi-bin directory,
19  * to keep it from getting changed.
20  */
21
22 include("phpagi.php");
23
24 $agi = new AGI;
25
26 if (!isset($argv[1])) {
27         $agi->verbose("Missing list");
28         exit(1);
29 }
30
31 if (!isset($argv[2])) {
32         $agi->verbose("Missing item");
33         exit(1);
34 }
35
36 if (!isset($argv[3])) {
37         $agi->verbose("Missing return var name");
38         exit(1);
39 }
40
41 $arglist = $argv[1];
42 $argitem = $argv[2];
43 $argvarname = $argv[3];
44
45 if (isset($argv[4])) {
46         $argsep = "&";
47 } else {
48         $argsep = $argv[4];
49 }
50
51 $newlist = str_replace($argitem.$argsep, "", $arglist.$argsep);
52
53 if (substr($newlist, -1, 1) == $argsep) {
54         $newlist = substr($newlist, 0, -1);
55 }
56
57 $agi->set_variable($argvarname, $newlist);
58 ?>
Note: See TracBrowser for help on using the browser.