Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
wvirtual.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /** WHAT Create another database
8  *
9  * @author Anakeen 2004
10  * @version $Id: wvirtual.php,v 1.9 2008/05/06 08:43:33 jerome Exp $
11  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
12  * @package FDL
13  */
14 /**
15  */
16 
17 include ("WHAT/Lib.Common.php");
18 include ("WHAT/wncurses.php");
19 include ("WHAT/wenv.php");
20 
21 global $_SERVER;
22 
23 if ($_SERVER['HTTP_HOST'] != "") {
24  print "<BR><H1>:~(</H1>";
25  exit;
26 }
27 
28 $dbank = getenv("dbanakeen");
29 $dbaccess = "user=anakeen dbname=$dbank";
30 $dbfree = "free$dbank";
31 if ($argv[1] != "") $dbfree = $argv[1];
32 
33 ncurses_winit(sprintf(_("Create other database for %s (%s)") , trim(`hostname -f`) , trim(`hostname -i`)));
34 ncurses_getmaxyx($fullscreen, $lines, $columns);
35 //---------------------------------------------------
36 $lhost = exec("dig `domainname` axfr | grep `hostname -f` | grep CNAME | awk '{print $1}'", $outlist, $ret);
37 if (count($outlist) == 0) {
38  ncurses_error(_("I can't find hostname alias"));
39 }
40 
41 foreach ($outlist as $k => $v) {
42  $post[] = substr($v, 0, -1);
43 }
44 
45 $wact = ncurses_newwin($lines - 9, $columns - 4, 7, 2);
46 ncurses_wborder($wact, 0, 0, 0, 0, 0, 0, 0, 0);
47 ncurses_wcolor_set($wact, 3);
48 
49 $select = ncurses_select($post, "Select context");
50 
51 $context = $post[$select];
52 
53 ncurses_mvaddstr($lines - 2, 4, _("Enter name for database ? "));
54 
55 $dbank = strtolower(ncurses_getln());
56 ncurses_wclear($wact);
57 
58 ncurses_mvwaddstr($wact, 3, 4, sprintf(_("Context : [%s]") , $context));
59 ncurses_mvwaddstr($wact, 5, 4, sprintf(_("Database : [%s]") , $dbank));
60 
61 ncurses_wrefresh($wact);
62 
63 initDbContext($dbank, $context, $dbank . "core", $dbank . "freedom", "localhost", "5432", "anakeen");
64 
65 $cpress = strtoupper(chr($pressed));
66 
67 ncurses_mvaddstr($lines - 2, 4, _("Continue (Y|N) ?") . str_repeat(" ", 40));
68 $pressed = ncurses_getch(); // wait for a user keypress
69 $cpress = strtoupper(chr($pressed));
70 if ($cpress != "Y") exit(1);
71 
72 ncurses_end();
73 
74 exit(0);
75 ?>
← centre documentaire © anakeen - published under CC License - Dynacase