diff options
author | Eudyptula <eitan@mosenkis.net> | 2009-06-19 14:23:12 -0400 |
---|---|---|
committer | Eudyptula <eitan@mosenkis.net> | 2009-06-19 14:23:12 -0400 |
commit | 5494492326fe0f7ea6127cfeaa1858e3c03a7da0 (patch) | |
tree | f7ce84b76ef22067270a75bb63bb2d3f5d88ee87 /frontend | |
parent | Updated todo (diff) | |
download | ingenue-5494492326fe0f7ea6127cfeaa1858e3c03a7da0.tar.gz ingenue-5494492326fe0f7ea6127cfeaa1858e3c03a7da0.tar.bz2 ingenue-5494492326fe0f7ea6127cfeaa1858e3c03a7da0.zip |
Transitioned to support multiple profiles, chosen in the frontend, to use data in Packages file header, began restructuring of frontend build creator
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/functions/r_stripslashes.php | 13 | ||||
-rw-r--r-- | frontend/index.php | 4 | ||||
-rw-r--r-- | frontend/pages/wizard.php | 56 |
3 files changed, 36 insertions, 37 deletions
diff --git a/frontend/functions/r_stripslashes.php b/frontend/functions/r_stripslashes.php new file mode 100644 index 0000000..8d6dccb --- /dev/null +++ b/frontend/functions/r_stripslashes.php @@ -0,0 +1,13 @@ +<?php +function r_stripslashes(&$array) { + debug('r_stripslashes', print_r($array, true)); + foreach ($array as $key => $value) { + if (is_array($value)) { + $array[$key]=r_stripslashes($value); + } elseif (is_string($value)) { + $array[$key]=stripslashes($value); + } + } + return $array; +} +?> diff --git a/frontend/index.php b/frontend/index.php index 846a3f9..0677c58 100644 --- a/frontend/index.php +++ b/frontend/index.php @@ -7,9 +7,7 @@ require_once('include/constants.php'); require_once(SHARED.'/config.php'); require_once('include/setup.php'); register_shutdown_function('onshutdown', realpath('include/footer.php'), realpath('include/header.php')); -foreach ($_REQUEST as $key => $value) { - $request[$key]=get_magic_quotes_gpc()?stripslashes($value):$value; -} +$request=get_magic_quotes_gpc()?r_stripslashes($_REQUEST):$_REQUEST; $routing=fopen('routing.csv', 'r'); for ($line=fgets($routing, 32768); !feof($routing); $line=fgets($routing, 32768)) { $line=trim($line, "\r\n"); diff --git a/frontend/pages/wizard.php b/frontend/pages/wizard.php index 2e0066c..dee3c57 100644 --- a/frontend/pages/wizard.php +++ b/frontend/pages/wizard.php @@ -1,44 +1,32 @@ <?php function init_wizard() { - if (isset($GLOBALS['S']['user'])) { - return array('title' => 'Image Creator'); + global $S, $request; + // TODO we shouldn't have to set the step this way, it should be stored in SQL + if (isset($S['user'])) { + if (isset($request['finished'])) { + return 'wizard/end'; + } elseif (isset($request['step']) && is_array($request['step']) && count($request['step']) == 1) { + $keys=array_keys($request['step']); + if (is_numeric($keys[0]) && is_file(FRONTEND.'/pages/wizard/step'.$keys[0].'.php')) { + return 'wizard/step'.$keys[0]; + } else { + debug('Not numeric, or file not existant for '.$keys[0]); + } + } + return array('title' => 'Create'); } else { return 'login'; } } function body_wizard() { - global $request, $S; - if (isset($request['submit'])) { - $fails=0; - while (true) { - $id=randstring(6); - debug("Trying id=$id..."); - // Maybe we should query the DB, not see if insert fails? - $build=new sql_build($id, $S['user']->id, $request['name'], 'build/ready', null, null); - try { - if ($build->write()) { - if (is_dir(WORK.'/build-'.$id)) { - debug('failed... directory already exists (this is bad - it should be in the database)'); - $build->delete(); - } else { - break; - } - } - } catch (Exception $e) { - if (get_class($e) != 'PDOException' || !isset($e->errorInfo) || !isset($e->errorInfo[0]) || $e->errorInfo[0] != 23000) { - throw ($e); - } else { - debug('already taken in the database'); - } - } - if (++$fails >= 10) { - die(print_error('Something is wrong - failed 10 times to choose a unique build id')); -die; - } - } - echo '<h3>Build submitted</h3><p><b>ID: '.$id.'</b></p><p>Check your build\'s status <a href="'.url('logs/build'.$id).'">here</a>.</p>'; - } else { - echo '<form action="'.url('create').'" method="post"><h3>Request an image built</h3>Name of your build (optional): <input name="name" /><br/><input type="submit" name="submit" value="Submit" /></form>'; + global $S; + echo '<form action="'.url('create').'" method="post"><h3>Request an image built</h3>Name of your build (optional): <input name="name" /><br/>Profile: <select name="pkgdir">'; + $r=$S['pdo']->query('SELECT * FROM `profiles` WHERE `flags` NOT LIKE "%d%"'); // d for disabled + while ($profile=$r->fetch(PDO::FETCH_ASSOC)) { + $profile=new sql_profile($profile); + $display=$profile->name?$profile->name:($profile->pkgdir?$profile->pkgdir:'/'); + echo '<option value="'.htmlentities($profile->pkgdir).'">'.htmlentities($display).'</option>'; } + echo '</select><br/><input type="submit" name="step[1]" value="Start" /></form>'; } ?> |