j'ai ajoute le message d'erreur WARNING you have not selected a database
[bazdig.git] / bazdig / console / index.php
blobf951c495da937d439d4817309bce445400e44e7e
1 <?php
2 if ( "5" > phpversion()) {
3 $error = "<b>ERROR</b> Bazdig works only with PHP5. sorry.";
4 die("<div style='background-color: yellow; border: 2px solid red; padding: 10px; margin: 10px;'>$error</div>");
6 session_start();
8 define('WARAQ_ROOT', '../..');
9 require_once WARAQ_ROOT .'/'. 'ini.php';
11 require_once "database.php";
13 if (!$_SESSION['db_type']) {
14 header('Location: '. $bazdig->get('/db')->url );
17 $bazdig_db = $bazdig->getparam('db')->file;
18 if (!is_writable($bazdig_db)) {
19 $error = "<b>WARNING</b> your history database is not writeable. <code>chmod 777 ". $bazdig->file ." && chmod 666 $bazdig_db</code></div>";
20 echo "<div style='background-color: yellow; border: 2px solid red; padding: 10px; margin: 10px;'>$error</div>";
23 try {
24 $work_db = new BDB(array('type' => $_SESSION['db_type'], 'name' => $_SESSION['db_name'], 'host' => $_SESSION['db_host']), $_SESSION['db_user'], $_SESSION['db_password']);
25 } catch (Exception $e) {
26 $error = "<b>ERROR</b> check that the PDO_SQLITE and PDO_MYSQL modules are installed";
27 die("<div style='background-color: yellow; border: 2px solid red; padding: 10px; margin: 10px;'>$error</div>");
31 <html>
32 <head>
33 <title>bazdig</title>
34 <script src="../codepress/codepress.js" type="text/javascript"></script>
35 <link rel="stylesheet" type="text/css" href="../bazdig.css" />
36 </head>
37 <body>
38 <div id="nav">
39 <a href="../history/" accesskey="h" title="(h)">history</a><a href="../db/" accesskey="d" title="(d)">database</a>
40 </div>
42 <form method="get" action="../sql/exec/" target="_new">
44 <div id="console">
45 <textarea id="input" name="input" class="codepress sql linenumbers-off" style="width:100%;height:350px;" wrap="off" tabindex="1">
46 <?php echo stripslashes($_GET['q']); ?>
47 </textarea>
48 <button id="ok" accesskey="k" title="(k)" onclick="q.value=input.getCode(); submit();">OK</button>
49 <input type="hidden" name="q" id="q"/>
50 </div>
51 <div id="schema">
52 <?php
54 if ($work_db->name) {
55 $dbName = $work_db->name;
56 $dbLocation = $work_db->host;
57 if ($work_db->type == 'sqlite' || $work_db->type == 'sqlite2') {
58 $dbLocation = dirname($dbName);
59 $dbName = basename($dbName);
61 echo "<h3>".$dbName."</h3>";
62 echo " @". $dbLocation;
63 echo $work_db->httpGet($bazdig->get('/db/schema/'));
64 } else {
65 $error = "<b>WARNING</b> you have not selected a database";
66 echo "<div style='background-color: yellow; border: 2px solid red; padding: 10px; margin: 10px;'>$error</div>";
69 </div>
71 </form>
73 </body>
74 </html>