source: src/webservice/htdocs/setup.php@ 8f38d1e

Last change on this file since 8f38d1e was 92c9c7c, checked in by Joachim Langenbach <joachim.langenbach@…>, 11 years ago
  • Improved htaccess rewrite rule (but not working right now)
    • started to implement database connection
    • Improved host url handling
    • Improved external handling

Signed-off-by: Joachim Langenbach <joachim.langenbach@…>

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[92c9c7c]1<?php
2/*
3 Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 MA 02110-1301 USA.
19*/
20
21require_once("config/config.php");
22require_once("inc/DatabaseHandler.php");
23
24function printError($message)
25{
26 echo "<div class=\"error\">\n";
27 echo " <h3>The following error occured:</h3>\n";
28 echo $message;
29 echo "</div>\n";
30}
31
32function printResult($result, $message)
33{
34 $class = "success";
35 $icon = "dialog-ok-apply.png";
36 if(!$result){
37 $class = "error";
38 $icon = "dialog-cancel.png";
39 }
40 echo "<li class=\"". $class ."\"><img src=\"resources/icons/". $icon ."\"/>". $message ."</li>\n";
41}
42
43?>
44
45<html>
46 <head>
47 <title>SiWeather Webservice Configuration</title>
48 <link rel="stylesheet" type="text/css" link="resources/css/webservice.css"/>
49 </head>
50 <body>
51 <h1>Welcome for the setup of the webservice backend for SiWeather</h1>
52 <ul>
53<?php
54
55$db = new DatabaseHandler();
56$dbFile = $db->databaseFile();
57if(is_null($dbFile)){
58 printResult(false, "No database file given (". $db->lastErrorMessage() .")");
59}
60
61$dbDirectory = pathinfo($dbFile, PATHINFO_DIRNAME);
62if(empty($dbDirectory)){
63 printResult(false, "Failed to extract directory from database file path ("+ $dbFile +")");
64}
65else{
66 if(is_dir($dbDirectory)){
67 printResult(true, "Database directory exists (". $dbDirectory .")!");
68 }
69 else{
70 if(!mkdir($dbDirectory)){
71 printResult(false, "Failed to create database directory (". $dbDirectory .")!");
72 }
73 else{
74 printResult(true, "Created directory ". $dbDirectory ." as database directory");
75 }
76 }
77
78 if(!is_writable($dbDirectory)){
79 printResult(false, "Database directory is not writable (". $dbDirectory .")!");
80 }
81 if($db->connect()){
82 printResult(true, "Connection to database established!");
83 }
84 else{
85 printResult(false, "Could not connect to the database (". $db->lastErrorMessage() .")");
86 }
87}
88
89?>
90 </ul>
91 </body>
92</html>
Note: See TracBrowser for help on using the repository browser.