PhpLabWare version 0.3 
/plugins/ -> ipnumbers_plugin.php

1  <?php
2 
3  // plugin_inc.php - skeleton file for plugin codes
4  // plugin_inc.php - author: Nico Stuurman
5 
6  /*
7  Copyright 2002, Nico Stuurman
8 
9  This is a skeleton file to code your own plugins.
10  To use it, rename this file to something meaningfull,
11  add the path and name to this file (relative to the phplabware root)
12  in the column 'plugin_code' of 'tableoftables', and code away.
13  And, when you make something nice, please send us a copy!
14 
15  This program is free software: you can redistribute it and/ormodify it under
16  the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
17 
18  */
19 
20 
21  /*
22 
23  ////
24  // !Change/calculate/check values just before they are added/modified
25  // $fieldvalues is an array with the column names as key.
26  // Any changes you make in the values of $fieldvalues will result in
27  // changes in the database.
28  // You could, for instance, calculate a value of a field based on other fields
29  function plugin_check_data($db,&$fieldvalues,$table_desc,$modify=false)
30  {
31  }
32 
33 
34  ////
35  // !Extends the search query
36  // $query is the complete query that you can change and must return
37  // $fieldvalues is an array with the column names as key.
38  // if there is an $existing_clause (boolean) you should prepend your additions
39  // with ' AND' or ' OR', otherwise you should not
40  function plugin_search($query,$fieldvalues,$existing_clause)
41  {
42     return $query;
43  }
44  */
45 
46  ////
47  // !Extends function getvalues
48  // $allfields is a 2-D array containing the field names of the table in the first dimension
49  // and name,columnid,label,datatype,display_table,display_record,ass_t,ass_column,
50  // ass_local_key,required,modifiable,text,values in the 2nd D
51  function plugin_getvalues($db,&$allfields,$id)
52  {
53     if (!$id)
54        return false;
55     for ($i=0; $i<sizeof($allfields); $i++) {
56        if ($allfields[$i]["name"]=="ipnumber") {
57           $ipnumber=$allfields[$i]["values"];
58           $ipoffset=$i;
59        }
60        if ($allfields[$i]["name"]=="online") {
61           $onlineoffset=$i;
62        }
63     }
64     $resultcode=true;
65     $ipnumber=$allfields[$ipoffset]["values"];
66     if ($ipnumber)
67         $result=exec("ping -c 1 -w 1 $ipnumber",$dummy,$resultcode);
68     
69     if (!$resultcode)
70        $allfields[$onlineoffset]["text"]="<b>Online</b>";
71     else
72        $allfields[$onlineoffset]["text"]="Offline";
73  }
74 
75  ?>


Generated: Sun Oct 5 21:17:35 2003 SourceForge Logo Generated by PHPXref 0.2