j'ai ajoute un message d'erreur pour le cas ou la base n'est pas ouverte en ecriture...
[bazdig.git] / bazdig / console / index.php
blob7364af6dd4d791a58bbb1a81897cbbd308acfe3c
1 <?php
2 session_start();
4 define('WARAQ_ROOT', '../..');
5 require_once WARAQ_ROOT .'/'. 'ini.php';
7 require_once "database.php";
9 if (!$_SESSION['db_type']) {
10 header('Location: '. $bazdig->get('/db')->url );
14 <html>
15 <head>
16 <title>bazdig</title>
17 <script src="../codepress/codepress.js" type="text/javascript"></script>
18 <link rel="stylesheet" type="text/css" href="../bazdig.css" />
19 </head>
20 <body>
21 <?php
22 $bazdig_db = $bazdig->getparam('db')->file;
23 if (!is_writable($bazdig_db)) {
24 echo '<div id="error"><b>WARNING</b> your history database is not writeable. <code>chmod 777 '. $bazdig->file .' && chmod 666 '. $bazdig_db .'</code></div>';
27 <div id="nav">
28 <a href="../history/" accesskey="h" title="(h)">history</a><a href="../db/" accesskey="d" title="(d)">database</a>
29 </div>
31 <form method="get" action="../sql/exec/" target="_new">
33 <div id="console">
34 <textarea id="input" name="input" class="codepress sql linenumbers-off" style="width:100%;height:350px;" wrap="off" tabindex="1">
35 <?php echo stripslashes($_GET['q']); ?>
36 </textarea>
37 <button id="ok" accesskey="k" title="(k)" onclick="q.value=input.getCode(); submit();">OK</button>
38 <input type="hidden" name="q" id="q"/>
39 </div>
40 <div id="schema"><?php
42 if ($_SESSION['db_type']) {
43 $work_db = new BDB(array('type' => $_SESSION['db_type'], 'name' => $_SESSION['db_name'], 'host' => $_SESSION['db_host']), $_SESSION['db_user'], $_SESSION['db_password']);
44 $dbName = $work_db->name;
45 $dbLocation = $work_db->host;
46 if ($work_db->type == 'sqlite' || $work_db->type == 'sqlite2') {
47 $dbLocation = dirname($dbName);
48 $dbName = basename($dbName);
50 echo "<h3>".$dbName."</h3>";
51 echo " @". $dbLocation;
52 echo $work_db->httpGet($bazdig->get('/db/schema/'));
56 </div>
58 </form>
60 </body>
61 </html>