Ticket #1409: seagull.patch_ip.replicate

File seagull.patch_ip.replicate, 2.3 kB (added by zeph1r, 5 years ago)

configuration replication / bad HACK

Line 
1 Index: lib/SGL/Config.php
2 ===================================================================
3 --- lib/SGL/Config.php  (revision 163)
4 +++ lib/SGL/Config.php  (working copy)
5 @@ -57,6 +57,53 @@
6          if ($this->isEmpty() && $autoLoad) {
7              $configFile = SGL_VAR_DIR  . '/'
8                  . SGL_Task_SetupPaths::hostnameToFilename() . '.conf.php';
9 +
10 +       // HACK to avoid hostname problem -> WebPlayer
11 +        $tmp = &SGL_ParamHandler::singleton($configFile);
12 +        $data = $tmp->read();
13 +               //print '<pre>'; die(print_r($data));
14 +        if ($data == false) {
15 +
16 +                       //SGL::displayStaticPage('Copio DEFAULTWEBPLAYER.conf.php e sostituisco la stringa interna');
17 +                       $defaultFile = SGL_VAR_DIR  . '/DEFAULTWEBPLAYER.conf.php';
18 +
19 +                       if (!@copy($defaultFile, $configFile))
20 +                               SGL::displayStaticPage('Non posso copiare il file di configurazione di default');
21 +
22 +            // Determine the host name
23 +            if (!empty($_SERVER['SERVER_NAME'])) {
24 +                $hostName = $_SERVER['SERVER_NAME'];
25 +
26 +            } elseif (!empty($_SERVER['HTTP_HOST'])) {
27 +                //  do some spoof checking here, like
28 +                //  if (gethostbyname($_SERVER['HTTP_HOST']) != $_SERVER['SERVER_ADDR'])
29 +                $hostName = $_SERVER['HTTP_HOST'];
30 +            } else {
31 +                //  if neither of these variables are set
32 +                //  we're going to have a hard time setting up
33 +                die('Could not determine your server name');
34 +            }
35 +            // Determine if the port number needs to be added onto the end
36 +            if (!empty($_SERVER['SERVER_PORT'])
37 +                    && $_SERVER['SERVER_PORT'] != 80
38 +                    && $_SERVER['SERVER_PORT'] != 443) {
39 +                $hostName .= ':' . $_SERVER['SERVER_PORT'];
40 +            }
41 +       
42 +                       unset($tmp);
43 +                       unset($data);
44 +
45 +               $tmp = &SGL_ParamHandler::singleton($configFile);
46 +               $data = $tmp->read();
47 +
48 +                       // no https because WE DO NOT SUPPORT https !!!
49 +                       $data['site']['baseUrl'] = 'http://'.$hostName;
50 +
51 +               $data = $tmp->write($data);
52 +
53 +        }
54 +       // END HACK
55 +
56              $conf = $this->load($configFile);
57              $this->fileName = $configFile;
58              $this->replace($conf);
59 @@ -230,4 +277,4 @@
60          return $ret;
61      }
62  }
63 -?>
64 \ No newline at end of file
65 +?>