[wpkg_web] / hosts_list.php Repository:
ViewVC logotype

View of /hosts_list.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (download) (annotate)
Thu Jan 11 02:13:58 2007 UTC (11 years, 10 months ago) by linuxkidd
File size: 10559 byte(s)
Language pack and Icon pack conversion complete.
Moved all settings into config.php.
Added CHANGELOG.
Fixed bug in packages_xml_in which prevented proper creation of initial level.
Added UPGRADE instructions.

<?php
  
include "connect.php";
  include 
"header.php";
  
$page='hlist';
  if(isset(
$_GET['reorder'])) {
    
$reorder=1;
    print 
"<script src=\"reorder.js\" language=\"JavaScript\"></script>\n";
  } else {
    
$reorder=0;
  }
  if(isset(
$_GET['new'])) {
    
$new=1;
  } else {
    
$new=0;
  }
  if(isset(
$_GET['host_id'])) {
    
$host_id=$_GET['host_id'];
  } else {
    
$host_id=0;
  }
?>
<script type="text/javascript">
// Tool Tip Data below
var preFormat="<div class='tip'>";
var postFormat="</div>";
var permDel="<span style=\"background: red; font-weight: bold;color: white;\"><?php print $vocab['tip-host_permdel']; ?></span>";

</script>
    <title><?php print $vocab['title-hostlist']; ?></title>
  </head>
  <body>
  <div id="popupDiv" style="visibility:hidden; position:absolute; z-index:1000;"></div>
    <form name='hosts' id='hosts' method='get' action='hosts_sub.php'<?php
    
if($reorder) {
      print 
' onSubmit="selectAll(this.id_list)"';
    }
    
?>>
    <table class='tbl_main'>
      <tr>
<?php
  $key
=array(7,8,5);
  include 
"sidebar.php";
  
$page='general';
  
$sql="select count(id) from hosts";
  
$sql_handle=mysql_query($sql) or error_report($sql,mysql_error());
  list(
$host_count)=mysql_fetch_array($sql_handle);

?>
        <td valign='top'>
          <table class='tbl_mainsub'>
            <tr class='headline'>
              <td><?php print $vocab['title-hostlist']; ?></td>
            </tr>
            <tr class='tr_main'>
              <td>

          <table class='tbl_sub2' style='width: 500px;' cellpadding='0' cellspacing='0'>
<?php
          
if($reorder) {
            
reorder_list();
          } else {
?>
            <tr class='headline'>
              <td colspan='2' align='right'><?php
              
if($host_count>4) {
                print 
"&nbsp; <input type='button' onclick='window.location=\"hosts_list.php?&reorder=1\"' value=\"{$vocab['button-mass_reorder']}\" " .
                  
"style='font-weight: normal;'>";
              } else {
                print 
"&nbsp;";
              } 
?></td>
              <td width='250px' align='center'><input type='button' onclick='window.location="hosts_list.php?&new=1"' value="<?php print $vocab['button-add']; ?>" style='font-weight: normal;'> &nbsp; <?php print $vocab['title-hostregex']; ?> <a href='javascript:void(0);' onMouseOver='return showTip(event, "<?php print $vocab['tip-host_regex']; ?>", true);' onMouseOut='return hideTip();'><?php print $icon['question'][0]; ?></a>
              </td>
              <td align='center'><?php print $vocab['title-profile']; ?> <a href='javascript:void(0);' onMouseOver='return showTip(event, "<?php print $vocab['tip-host_prof']; ?>", true);' onMouseOut='return hideTip();'><?php print $icon['question'][0]; ?></a></td>
            </tr>
        <?php
          $sql
="select hosts.id as id,priority,regex,prof_id,profiles.name as name from hosts left join profiles on ( hosts.prof_id=profiles.id ) order by priority";
          
$sql_handle=mysql_query($sql) or error_report($sql,mysql_error());
          
$count=0;
          while(
$host_info=mysql_fetch_array($sql_handle)) {
            
$count++;
            
$status='';
            if(
$host_id==$host_info['id']) {
              print 
"      <input type='hidden' name='host_id' value='{$host_info['id']}'>\n";
              print 
"      <tr style='background: {$alt_bg_colors[$count%2]};'>\n";
              print 
"        <td colspan='2'>&nbsp;</td>\n";
              print 
"        <td align='center'><input type='text' name='regex' id='regex' size='15' maxlength='100' value='" htmlspecialchars($host_info['regex']) . "'></td>\n";
              print 
"        <td align='center'><select id='prof_id' name='prof_id'>\n";
              
$sql2="select * from profiles order by name";
              
$sql2_handle=mysql_query($sql2) or error_report($sql2,mysql_error());
              while(
$prof_data=mysql_fetch_array($sql2_handle)) {
                print 
"           <option value='{$prof_data['id']}'";
                if(
$host_info['prof_id']==$prof_data['id']) {
                  print 
" SELECTED";
                }
                print 
">{$prof_data['name']}</option>\n";
              }
              print 
"          </select>\n";
              print 
"        </td>\n";
              print 
"      </tr>\n";
              print 
"      <tr style='background: {$alt_bg_colors[$count%2]};'>\n";
              print 
"        <td colspan='2'>&nbsp;</td><td align='center'><input type='submit' id='update' name='update' value='Update'> &nbsp; <input type='button' onclick='window.location=\"hosts_list.php\"' value='Cancel'></td><td>&nbsp;</td>\n";
              print 
"      </tr>\n";
              continue;
            }
            
$xmllink="<a href='hosts_xml_out.php?id={$host_info['id']}' onMouseOver='return showTip(event, \"{$vocab['tip-host_xml-1']}\", true);' onMouseOut='return hideTip();'>{$icon['xml'][0]}</a>";
            
$link="<a href='hosts_list.php?host_id={$host_info['id']}' title='{$vocab['tip-host_edit']}'>";
            if(
$count>1) {
              
$status.="<a href='hosts_sub.php?host_id={$host_info['id']}&dir=1&pri={$host_info['priority']}' title='^'>{$icon['up'][0]}</a>";
            } else {
              
$status.=$icon['space'][0];
            }
            if(
$host_count>&& $count<$host_count) {
              
$status.="<a href='hosts_sub.php?host_id={$host_info['id']}&dir=3&pri={$host_info['priority']}' title='v'>{$icon['down'][0]}</a>";
            } else {
              
$status.=$icon['space'][0];
            }
            
$status.="<a href='hosts_sub.php?del={$host_info['id']}' onMouseOver='return showTip(event, permDel, true);' onMouseOut='return hideTip();' onClick=\"return confirm('{$vocab['popup-host_permdel']} {$vocab['gen-confirm']}');\">{$icon['delete'][0]}</a>";
            
$style='';
            print 
"      <tr style='background: {$alt_bg_colors[$count%2]};'>\n";
            print 
"        <td  style='text-align: center; width: 57px;'>{$status}</td>\n";
            print 
"        <td  style='text-align: center;'>{$xmllink}</td>\n";
            print 
"        <td  style='{$style}; text-align: center;'>{$link}{$host_info['regex']}</td>\n";
            print 
"        <td align='center'>{$link}{$host_info['name']}</a></td>\n";
            print 
"      </tr>\n";
          }
          
$count++;
          if(
$count<&& !$new) {
            print 
"      <tr style='background: {$alt_bg_colors[$count%2]};'>\n";
            print 
"        <td colspan='3'>{$vocab['gen-host_none']}</td>\n";
            print 
"      </tr>\n";
          }
          if(
$new) {
            print 
"      <input type='hidden' name='priority' value='{$count}'>\n";
            print 
"      <tr style='background: {$alt_bg_colors[$count%2]};'>\n";
            print 
"        <td colspan='2'>&nbsp;</td>\n";
            print 
"        <td align='center'><input type='text' name='regex' id='regex' size='15' maxlength='100'></td>\n";
            print 
"        <td align='center'><select id='prof_id' name='prof_id'>\n";
            
$sql2="select * from profiles order by name";
            
$sql2_handle=mysql_query($sql2) or error_report($sql2,mysql_error());
            while(
$prof_data=mysql_fetch_array($sql2_handle)) {
              print 
"           <option value='{$prof_data['id']}'>{$prof_data['name']}</option>\n";
            }
            print 
"          </select>\n";
            print 
"        </td>\n";
            print 
"      </tr>\n";
            print 
"      <tr style='background: {$alt_bg_colors[$count%2]};'>\n";
            print 
"        <td colspan='2'>&nbsp;</td><td align='center'><input type='submit' id='add' name='add' value='{$vocab['button-add']}'> &nbsp; <input type='button' onclick='window.location=\"hosts_list.php\"' value='{$vocab['button-cancel']}'></td><td>&nbsp;</td>\n";
            print 
"      </tr>\n";
          }
        }
        
?>
          </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
    <?php include "footer.php"?>
  </body>
</html>

<?php

function reorder_list() {
  global 
$alt_bg_colors,$vocab;
?>
  <tr>
     <th class='headline' align='center' colspan='3'><?php print $vocab['title-host_reorder']; ?></th>
  </tr>
  <tr>
    <td align='center' colspan='3'>
      <select id='id_list' name='id_list[]' multiple size='20'>
<?php
  $sql
="select hosts.id as id,hosts.priority as priority,regex,profiles.name as name from hosts left join profiles on hosts.prof_id=profiles.id order by priority";
  
$sql_handle=mysql_query($sql) or error_report($sql,mysql_error());

  
$count=0;
  while(
$package=mysql_fetch_array($sql_handle)) {
    print 
"        <option value='{$package['id']}'>{$package['regex']} ( {$package['name']} )</option>\n";
  }
?>
      </select>
    </td>
  </tr>
  <tr style='background: <?php print $alt_bg_colors[0]; ?>;'>
    <td align="right">
      <input style="width: 100px" type="button" onClick="moveOption(this.form.id_list, -1)"
         value="<?php print $vocab['button-up']; ?>" title="Up">
    </td>
    <td align="center">
      <input style="width: 100px" type="button" onClick="moveOptionVar(this.form.id_list, -1, 20)"
         value="<?php print $vocab['button-pageup']; ?>" title="Page Up">
    </td>
    <td align="left">
      <input style="width: 100px" type="button" onClick="moveOptionAllWay(this.form.id_list, -1)"
         value="<?php print $vocab['button-top']; ?>" title="Top">
    </td>
  </tr>
  <tr style='background: <?php print $alt_bg_colors[0]; ?>;'>
    <td align="right">
      <input style="width: 100px" type="button" onClick="moveOption(this.form.id_list, 1)"
         value="<?php print $vocab['button-down']; ?>" title="Down">
    </td>
    <td align="center">
      <input style="width: 100px" type="button" onClick="moveOptionVar(this.form.id_list, 1, 20)"
         value="<?php print $vocab['button-pagedown']; ?>" title="Page Down">
    </td>
    <td align="left">
      <input style="width: 100px" type="button" onClick="moveOptionAllWay(this.form.id_list, 1)"
         value="<?php print $vocab['button-bottom']; ?>" title="Bottom">
    </td>
  </tr>
  <tr style='background: <?php print $alt_bg_colors[0]; ?>;'>
    <td colspan="3" align="center">
      <input type="submit" name='save' id='save' value="<?php print $vocab['button-saveorder']; ?>"> &nbsp; <input type='button' name='cancel' id='cancel' value='<?php print $vocab['button-cancelorder']; ?>' onclick='window.location="hosts_list.php"'>
    </td>
  </tr>
<?php
}

?>

ViewVC Help
Powered by ViewVC 1.0.3