ActionApps PHP Cross Reference Groupware Applications

Source: /admin/se_nodes.php3 - 198 lines - 6655 bytes - Summary - Text - Print

   1  <?php
   2  /**  se_nodes.php3 - Remote node administration
   3   *
   4   *     expected    $mode
   5   *                 $name
   6   *                 $server_url
   7   *                 $password
   8   *     optionaly $Msg to show under <h1>Headline</h1> (typicaly: Fields' mapping update)
   9   *                 $old_node_name
  10   *                 $sel_node_name
  11   *
  12   * PHP versions 4 and 5
  13   *
  14   * LICENSE: This program is free software; you can redistribute it and/or modify
  15   * it under the terms of the GNU General Public License as published by
  16   * the Free Software Foundation; either version 2 of the License, or
  17   * (at your option) any later version.
  18   *
  19   * This program is distributed in the hope that it will be useful,
  20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22   * GNU General Public License for more details.
  23   *
  24   * You should have received a copy of the GNU General Public License
  25   * along with this program (LICENSE); if not, write to the Free Software
  26   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  27   *
  28   * @version   $Id: se_nodes.php3 2441 2007-06-29 12:41:44Z honzam $
  29   * @author    Honza Malik <honza.malik@ecn.cz>
  30   * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
  31   * @copyright Copyright (C) 1999, 2000 Association for Progressive Communications
  32   * @link      http://www.apc.org/ APC
  33   *
  34  */
  35  
  36  require_once  "../include/init_page.php3";
  37  
  38  if ( !isSuperadmin() ) {
  39      MsgPage($sess->url(self_base()."index.php3"), _m("You have not permissions to manage nodes"));
  40      exit;
  41  }
  42  $err["Init"]="";
  43  require_once  AA_INC_PATH."formutil.php3";
  44  
  45   if ($mode == "edit") {
  46       $db->query("SELECT * FROM nodes WHERE name='$sel_node_name'");
  47       if ($db->next_record()) {
  48           $old_node_name = $sel_node_name;
  49           $node_name = $db->f(name);
  50           $server_url = $db->f(server_url);
  51           $password = $db->f(password);
  52           $new_mode="update";
  53       }
  54    } else {
  55        switch ($mode) {
  56            case "delete" :
  57                $db->query("DELETE FROM nodes WHERE name='$sel_node_name'");
  58                $db->query("DELETE FROM ef_permissions WHERE node='$sel_node_name'");
  59                break;
  60  
  61            case "insert" :
  62                $db->query("SELECT * FROM nodes WHERE name='$node_name'");
  63                if ($db->next_record()) {
  64                    $err["DB"] .= MsgErr("Can't add node $node_name");
  65                } else {
  66                    $SQL = "INSERT INTO nodes VALUES('$node_name','$server_url','$password')";
  67                    if (!$db->query($SQL)) {  // not necessary - we have set the halt_on_error
  68                        $err["DB"] .= MsgErr("Can't add node $node_name");
  69                    }
  70                }
  71                break;
  72  
  73            case "update" :
  74                $db->query("UPDATE nodes SET name='$node_name', server_url='$server_url',
  75                                            password='$password' WHERE name='$old_node_name'");
  76                break;
  77  
  78            case "add" : $new_mode = "insert"; break;
  79        }
  80        $node_name = $server_url = $password = "";
  81        $new_mode = "insert";
  82  
  83     }
  84  
  85  $db->query('SELECT * FROM nodes ORDER BY name ');
  86  $nodes="";
  87  while ($db->next_record()) {
  88      $nodes[] = $db->f(name);
  89  }
  90  
  91  HtmlPageBegin();   // Print HTML start page tags (html begin, encoding, style sheet, but no title)
  92  ?>
  93   <title><?php echo _m("Remote node administration");?></title>
  94  <script language="javascript"><!--
  95  
  96  function InitPage() {}
  97  
  98  function SelectValue(sel) {
  99    svindex = eval(sel).selectedIndex;
 100    if (svindex != -1) { return eval(sel).options[svindex].value; }
 101    return null;
 102  }
 103  
 104  function ActionGo(mode) {
 105    if (mode== 'add') {
 106      document.frm.mode.value = mode;
 107      document.frm.submit();
 108    } else {
 109  
 110    sel = SelectValue('document.frm.nodes')
 111    if (sel == null)
 112      alert('<?php echo _m("No selected node"); ?>')
 113    else {
 114      if (mode == 'delete')
 115        if (!confirm('<?php echo _m("Are you sure you want to delete the node?"); ?>'))
 116          return
 117      document.frm.sel_node_name.value = sel
 118      document.frm.mode.value = mode;
 119      document.frm.submit();
 120    }
 121   }
 122  }
 123  
 124  function checkData() {
 125    if (document.frm.node_name.value=="") {
 126       alert('<?php echo _m("Node empty"); ?>')
 127       return false
 128    }
 129  }
 130  
 131  function Cancel() {
 132    document.location = "<?php echo $sess->url(self_base() . "index.php3")?>"
 133  }
 134  
 135  // -->
 136  </script>
 137  
 138  </head>
 139  
 140  <?php
 141    $useOnLoad = true;
 142    require_once  AA_INC_PATH."menu.php3";
 143    showMenu ($aamenus, "sliceadmin","nodes");
 144  
 145    echo "<h1><b>" . _m("Remote node administration") . "</b></h1>";
 146    PrintArray($err);
 147    echo $Msg;
 148  
 149    $form_buttons = array("submit","cancel"=>array("url"=>"se_fields.php3"));
 150  
 151  ?>
 152  
 153  <form method="post" name="frm" action="<?php echo $sess->url($_SERVER['PHP_SELF']) ?>" onsubmit="return checkData()">
 154  <?php
 155  
 156      FrmTabCaption(_m("Remote node administration"));
 157  ?>
 158        <tr><td colspan="2"><?php echo _m("Known remote nodes") ?></td></tr>
 159        <tr><td align="center" colspan="2">
 160        <select name="nodes" class="tabtxt" size="5">
 161        <?php
 162          if (isset($nodes) && is_array($nodes)) {
 163              reset($nodes);
 164              while (list(,$name) = each($nodes)){
 165                  echo "<option value=\"$name\">$name</option>";
 166              }
 167          }
 168        ?>
 169        </select>
 170      <tr><td colspan=2 align="center">
 171        <input type="button" value="<?php echo _m("Edit") ?>" onclick="ActionGo('edit');">
 172        <input type="button" value="<?php echo _m("Delete") ?>" onclick="ActionGo('delete');">
 173        <input type="button" value="<?php echo _m("Add") ?>" onclick="ActionGo('add');">
 174       </td></tr>
 175      <tr><td colspan="2">&nbsp;</td></tr>
 176  <?php
 177  
 178      FrmTabSeparator(($new_mode=="insert" ? _m("Add new node") : _m("Edit node data")));
 179  
 180  ?>
 181      <tr><td><?php echo _m("Node name") ?></td>
 182          <td><input type="text" name="node_name" size="40" value="<?php echo safe($node_name)?>" ><br><?php echo _m("Your node name")?>: "<?php echo ORG_NAME ?>"
 183      <tr><td><?php echo _m("URL of the getxml.php3") ?></td>
 184          <td><input type="text" name="server_url" size="40" value="<?php echo safe($server_url)?>" ><br><?php echo _m("Your getxml is")?>: "<?php echo AA_INSTAL_URL ?>admin/getxml.php3"
 185      <tr><td><?php echo _m("Password") ?></td>
 186           <td><input type="text" name="password" size="40" value="<?php echo safe($password)?>" >
 187      <input type="hidden" name="mode" value="<?php echo safe($new_mode) ?>">
 188      <input type="hidden" name="old_node_name" value="<?php echo safe($old_node_name) ?>">
 189      <input type="hidden" name="sel_node_name">
 190  <?php
 191      FrmTabEnd($form_buttons, $sess, $slice_id);
 192  
 193      echo "
 194      </form>";
 195  
 196  HtmlPageEnd();
 197  page_close()
 198  ?>

title

Description

title

Description

title

Description

title

title

Body