Файл: EasyHost v2.0/system/htdocs/admin/packages/create.pl
Строк: 36
<?php
$system->error('This feature has been disabled in demo mode') if $system->config('demo');
$system->error('You didn't enter a name for this package') if (!$system->param('name'));
$system->error('The name field length must not be longer then 100 characters') if (length($system->param('name')) > 100);
$system->error('There is already a package with that name in the database') if ($system->db->selectrow_array('SELECT id FROM packages WHERE name = ?',undef,$system->param('name')));
$system->db->do('INSERT INTO packages (name,date_created) VALUES (?,NOW())',undef,$system->param('name'));
my $package = EasyHost::Package->new($system->db->selectrow_array('SELECT id FROM packages ORDER BY id DESC LIMIT 1'));
if ($system->param('template') > 0)
{
my $select = $system->db->prepare('SELECT name,value FROM packages_config WHERE id = ?');
my $insert = $system->db->prepare('INSERT INTO packages_config VALUES (?,?,?)');
$select->execute($system->param('template'));
while (my @row = $select->fetchrow_array)
{
$insert->execute($package->id,@row);
}
$select->finish;
$insert->finish;
}
$system->db->do('REPLACE INTO config VALUES (?,?)',undef,'package_default',$package->id) if ($system->service->packages->count == 1);
$system->argv('&id='.$package->id);
$system->redirect('package/config');
?>