<?php
// $Header: /home/CVS/rps/lms/lms_file.php,v 1.9 2008/06/30 02:24:59 yoxel Exp $
/*
* ----START-LICENCE----
* Copyright 2002-2008 Yoxel Systems, Santa Clara, CA, USA (hide@address.com)
*
* This program is free software; you can redistribute it and/or
* modify it under 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
* -----END-LICENCE-----
*/
require_once('../includes/db.inc');
require_once('includes/lms/lms.inc');
$rts = new LicenseManager();
$pqs_2d=$rts->init_pqs();
// This part actually does some processing
require_once('includes/lms/keys_server_inc.php');
$page_title='License Management System';
$on_load_str="addkey(0,true,0);";
require_once('includes/header.inc');
$opt=0;
$allowed_pids=$rts->list_allowed_pqs();
$allowed_classes=$rts->list_allowed_classes();
$class=$user_params->pget('lms_file_class');
if(!$class)
$class=REQ_CLASS_LIC;
if(isset($_POST['which_button'])){
$wb=$_POST['which_button'];
$xok=TRUE;
$fields['class']=$_POST['class'];
if(!$_POST['account']){
$xok=FALSE;
_live_error('Please select an account.');
}
$fields['customer_id']=$_POST['account'];
$fields['synopsis']=stripslashes(trim($_POST['synop']));
if(!is_synopsis($fields['synopsis'])){
$xok=FALSE;
_live_error('Please enter valid synopsis, more than 4 characters long.');
}
$fields['description'] =str_replace("\r","",stripslashes($_POST['descr']));
if(!is_description($fields['description'])){
$xok=FALSE;
_live_error('Your description uses forbiden characters.');
}
if($is_customer){
$opt|=REQ_OPT_VBC;
}elseif(isset($_POST['vbc'])){
if(trim($_POST['vbc'])=='yes')
$opt|=REQ_OPT_VBC;
else
$opt&=~REQ_OPT_VBC;
}else
$opt&=~REQ_OPT_VBC;
$fields['options']=$opt;
if(isset($_POST['cc_list'])){
$cc_list=$_POST['cc_list'];
//echo "$cc_list <br>";
}else
$cc_list=FALSE;
$platform=$_POST['platform'];
$fields['hostid']=stripslashes(trim($_POST['hostid']));
if(!eregi("^[[:alnum:]_.]+$",$fields['hostid'])){
$xok=FALSE;
_live_error('Please enter valid hostid.');
}
if(isset($_POST['klist']))
$klist=explode(',',$_POST['klist']);
//echo "$pid && $syn && $class && $cust && $cpri && $d && $xok <br>";
if($xok){
$rid=$rts->file_request($fields,$cc_list);
if(count($klist)){
$keys=array();
foreach($klist as $kid){
if(isset($_POST['kun'.$kid]))
$keys[$kid]['kun']=$_POST['kun'.$kid];
if(isset($_POST['kad'.$kid]))
$keys[$kid]['kad']=$_POST['kad'.$kid];
if(isset($_POST['kmn'.$kid]))
$keys[$kid]['kmn']=$_POST['kmn'.$kid];
}
$rts->attach_keys($rid,$keys);
}
$user_params->pset('lms_file_class',$class);
$user_params->save();
_warning('Thank you for registering your request.');
header('Refresh: 2; '.$_SERVER['PHP_SELF']);
//header("Location: ".$_SERVER['PHP_SELF']);
exit();
}
}
// echo "$class <br>";
$cc_select=array();
$cc_select[$uid]=TRUE;
?>
<script language="JavaScript">
<!--
function go(form, wb){
if (sel_check(form.account))
return alert('Please, select account!');
if (text_check(form.synop))
return alert('Please, enter valid synopsis!');
if (sel_check(form.platform))
return alert('Please, select license server platformt!');
if (alnum_check(form.hostid))
return alert('Please, enter valid license server hostid!');
if (text_check(form.descr))
return alert('Please, enter description!');
if(form.booking.value)
if(num_check(form.booking))
return alert('Please, enter valid booking amount!');
collect_all(form);
form.which_button.value=wb;
form.submit();
disable_form(form);
}
//-->
</script>
<form name="lms_yoxel" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border='0' cellpadding='1' cellspacing='1' width='90%' class=dgray align="center">
<tr>
<th colspan=3>LMS: Submit Request</th>
</tr>
<tr style='height: 1' class='separator'>
<td colspan="3"></td>
</tr>
<tr class="lgray">
<th>Class</th>
<td colspan=2>
<select class="selec" name="class">
<?php
if(isset($_POST['class']))
$cs=$_POST['class'];
else
$cs=$class;
foreach ($rts->class2str as $k => $v){
echo "<option value='$k' ".($k == $cs?' selected':'').">$v</option>\n";
}
?>
</select>
</td>
</tr>
<tr class="lgray">
<th>Account</th>
<td colspan=2>
<select class="selec" name="account">
<option value="">=Account=</option>
<?php
if(isset($_POST['account']))
$cs=$_POST['account'];
else
$cs=$class;
foreach ($customers_2d['name'] as $k => $v){
if(!$k) continue;
echo "<option value='$k'".($k == $cs?' selected':'').">$v</option>\n";
}
?>
</select>
</td>
</tr>
<tr class="lgray">
<th>Synopsis</th>
<td colspan=2>
<input class="inp" type="text" name="synop" size="48" maxlength="127" value="<?php if(isset($_POST['synop'])) echo $_POST['synop']; ?>" />
</td>
</tr>
<tr class="lgray" align='left'>
<th align='center'>CC List</th>
<?php
$allowed_cc=array();
if($is_customer)
foreach($active_users as $u => $un){
if((($all_users_2d['user_is'][$u]&USER_IS_CUSTOMER)==0) || ($all_users_2d['user_is'][$u]&USER_IS_LOCKED) || ($all_users_2d['customer'][$u]!=$all_users_2d['customer'][$uid])) continue;
$allowed_cc[$u]=$all_users_2d['name'][$u];
}
else
foreach($active_users as $u => $un){
if($all_users_2d['user_is'][$u]&(USER_IS_CUSTOMER|USER_IS_LOCKED)) continue;
$allowed_cc[$u]=$all_users_2d['name'][$u];
}
$selhtml=gen_yxl_select('cc_list',$allowed_cc,&$cc_select,$with_order=FALSE,$long=TRUE);
echo '
<td colspan="2">'.$selhtml.'</td>';
?>
<tr class="lgray">
<th>License Server OS,Platform</th>
<td colspan=2>
<select name="platform" class="selec">
<?php
$platforms[0]='=Platform=';
if(isset($_POST['platform']))
$cs=$_POST['platform'];
else
$cs=0;
foreach ($platforms as $k => $v) {
if($k == $cs)
echo "<option value='$k' selected>$v</option>";
else
echo "<option value='$k'>$v</option>";
}
?>
</select>
</td>
</tr>
<tr class="lgray">
<th>License Server Host ID</th>
<td colspan=2>
<input class="inp" type="text" name="hostid" size="32" maxlength="127" value="<?php if(isset($_POST['hostid'])) echo $_POST['hostid']; ?>" />
</td>
</tr>
<tr class="lgray">
<th>Description</th>
<td colspan=2>
<textarea name="descr" rows="6" style="width: 98%"><?php
if(isset($_POST['descr'])) echo $_POST['descr']; ?></textarea>
</td>
</tr>
<tr class="lgray">
<th>Booking amount</th>
<td colspan=2>$
<input class="inp" type="text" name="booking" size="8" maxlength="10" value="<?php if(isset($_POST['hostid'])) echo $_POST['hostid']; ?>" />
</td>
</tr>
<tr style='height: 1' class='separator'>
<td colspan="3"></td>
</tr>
<tr class="lgray">
<th colspan="3">Construct a feature set from available license keys</th>
</tr>
<tr class="lgray small" align="center">
<td colspan="3">(this form also helps you estimate amounts you are supposed to book right away and bill later)</td>
</tr>
<tr class="lgray">
<th colspan="3"><select class="selec" style="width: 32em" name="pkid">
<?php
for($row=$rts->first_key();$row;$row=$rts->next_key())
echo '
<option value="'.$row['kid'].'">'.$pqs_2d['name'][$row['pid']].' - '.$row['summary'].'</option>';
?>
</select>
<input class="gbtn" type="button" value="Add Key" onClick="addkey(0)" >
<input class="sbtn" type="button" value="Recompute" onClick="recompute(this.form)" >
<input type="hidden" name="klist" value="" >
</th>
</tr>
<tr class="lgray">
<td colspan="3">
<div id="keys_list"></div>
</td>
</tr>
<tr style='height: 1' class='separator'>
<td colspan="3"></td>
</tr>
<tr style="background:white">
<td colspan="3" align="center">
<input type="hidden" name="rid" value="0">
<input type="hidden" name="which_button" value="">
<input class="wbtn" type="button" value="Submit Request" onClick="go(this.form, 'newkey')" >
</td>
</tr>
</table>
</form>
<?php require_once("includes/footer.inc"); ?>