source: trunk/install/tools.php @ 244

Revision 244, 2.2 KB checked in by sque, 11 months ago (diff)

Update copyrights holders with real name.

Line 
1<?php
2/*
3 * WiND - Wireless Nodes Database
4 *
5 * Copyright (C) 2011 K. Paliouras <squarious _at gmail [dot] com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 dated June, 1991.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21
22
23$_GLOBALS['root_path'] = dirname(__FILE__) . '/../';
24
25//! Create an absolute url for static content
26function surl($relative)
27{
28    return (dirname($_SERVER['SCRIPT_NAME']) != '/'? dirname($_SERVER['SCRIPT_NAME']):'') . $relative;
29}
30
31function abs_surl($absolute)
32{
33        $scheme = (isset($_SERVER['HTTPS']))?'https':'http';
34        return "$scheme://{$_SERVER['HTTP_HOST']}" . $absolute;
35}
36
37//! Return textual represenetation of result.
38function result_text($result)
39{
40        return (!$result?'fail':'success');
41}
42
43
44function show_error($message)
45{
46        echo "<div class=\"error\">$message</div>";
47}
48
49//! Check if request method is port
50function is_method_post()
51{
52        return $_SERVER['REQUEST_METHOD'] == 'POST';
53}
54
55function installation_session()
56{
57        /*
58         * Begin session
59         */
60        session_start();
61        define('ROOT_PATH', './');
62        if (!isset($_SESSION['config'])) {
63                require_once(dirname(__FILE__) . '/../config-sample/config.php');
64                $_SESSION['config'] = $config;
65       
66                // Add url staf
67                $_SESSION['config']['site']['domain'] = $_SERVER['HTTP_HOST'];
68               
69                $absolute = explode('/', surl('/'));
70                array_splice($absolute, -2);
71                $absolute = implode('/', $absolute ) . '/';
72                $_SESSION['config']['site']['url'] = abs_surl($absolute );     
73        }
74}
75
76function get_next_step($steps, $current)
77{
78        $step_keys = array_keys($steps);
79        $step_current_index = array_search($current, $step_keys);
80        return isset($step_keys[$step_current_index + 1])?$step_keys[$step_current_index + 1]:null;
81}
Note: See TracBrowser for help on using the repository browser.