[wpkg_web] / prof_gen_sub.php Repository:
ViewVC logotype

View of /prof_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: 1758 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";
  if(isset(
$_GET['type']) && $_GET['type']==1) {
    
$table='prof_packs';
    
$field='pack_id';
  } else if (isset(
$_GET['type'])) {
    
$table='prof_deps';
    
$field='dep_id';
  }
  if(isset(
$_GET['Submit'])) {
    
$sql="select id from profiles where name=" quote_smart($_GET['name']);
    
$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 ","Profile with name " quote_smart($_GET['name']) . " already exists.  Click <a href='profiles.php?prof_id=" $id "'>HERE</a> to edit that profile.");
    }
    
$sql=sprintf("insert into profiles values ( NULL, %s )"quote_smart($_GET['name']));
    
mysql_query($sql) or error_report($sql,mysql_error());
    
$_GET['prof_id']=mysql_insert_id();
  } else if(isset(
$_GET['Update'])) {
    
$sql=sprintf("update profiles set name=%s where id=%s"quote_smart($_GET['name']), quote_smart($_GET['prof_id']));
    
mysql_query($sql) or error_report($sql,mysql_error());
  }else if(isset(
$_GET['Add'])) {
    foreach(
$_GET[$field] as $pid) {
      
$sql=sprintf("insert into %s values ( %s, %s )"$tablequote_smart($_GET['prof_id']), quote_smart($pid));
      
mysql_query($sql) or error_report($sql,mysql_error());
      
$next_pri++;
    }
  } else if(isset(
$_GET['del'])) {
    
$sql=sprintf("delete from %s where %s=%s and prof_id=%s"$table$fieldquote_smart($_GET[$field]), quote_smart($_GET['prof_id']));
    
mysql_query($sql) or error_report($sql,mysql_error());
  }
  print 
"<META HTTP-EQUIV=Refresh content='0; URL=profiles.php";
  if(isset(
$_GET['prof_id'])) {
    print 
"?prof_id=" $_GET['prof_id'];
  }
  print 
"'>";
?>

ViewVC Help
Powered by ViewVC 1.0.3