[wpkg_web] / pack_gen_sub.php Repository:
ViewVC logotype

View of /pack_gen_sub.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (download) (annotate)
Fri Jan 19 14:39:45 2007 UTC (11 years, 8 months ago) by linuxkidd
File size: 1525 byte(s)
Added duplicate entry checks based on idtxt for packages, name for profiles, and regex for hosts.

<?php
  
include "connect.php";
  include 
"header.php";
  
$pack_fields=array('name','version','obsolete','idtxt','reboot','priority','exeonce','notes');
  if(isset(
$_GET['submit'])){
    if(isset(
$_GET['pack_id'])) {
      
$pack_id=$_GET['pack_id'];
      
$sql='update packages set ';
      
$count=0;
      foreach (
$pack_fields as $field) {
        if(isset(
$_GET[$field])) {
          if(
$count) {
            
$sql.=",";
          }
          
$count=1;
          
$sql.=sprintf(" %s=%s",$field,quote_smart($_GET[$field]));
        }
      }
      
$sql.=" where id=" quote_smart($pack_id);
    } else {
      
$sql="select id from packages where idtxt=" quote_smart($_GET['idtxt']);
      
$sql_handle=mysql_query($sql) or error_report($sql,mysql_error());
      list(
$id)=mysql_fetch_array($sql_handle);
      if(isset(
$id) && !empty($id)) {
        
error_report("Error: ","Package with ID " quote_smart($_GET['idtxt']) . " already exists. Click <a href='packages.php?pack_id=" $id "'>HERE</a> to edit that package.");
      }
      
$sql="insert into packages values ( NULL";
      foreach (
$pack_fields as $field) {
        
$sql.= ", " quote_smart($_GET[$field]);
      }
      
$sql.=")";
    }
    
$sql_handle=mysql_query($sql) or error_report($sql,mysql_error());
    if(!isset(
$pack_id)) {
      
$pack_id=mysql_insert_id();
    }
    print 
"<META HTTP-EQUIV=Refresh content='0; URL=packages.php?pack_id=" $pack_id "'>";
  } else {
    print 
"<META HTTP-EQUIV=Refresh content='0; URL=packages.php'>";
  }
?>

ViewVC Help
Powered by ViewVC 1.0.3