File: multisite.php

package info (click to toggle)
spip 3.0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 30,776 kB
  • sloc: php: 200,550; xml: 4,367; sh: 272; makefile: 39
file content (36 lines) | stat: -rw-r--r-- 888 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

// Custom include for spip multisite under debian

// First define a global variable for multiple sites:
$GLOBALS['spip_sites'] = array();

// Now include all defined sites:
$dir = "/etc/spip/sites";

// Including all enabled sites.
if ( is_dir( $dir )
   &&
     $dh = opendir( $dir ) ) {
        while ( ( $file = readdir( $dh ) ) !== false ) {
	    if ( preg_match( "/.php$/",$file ) && is_readable($dir . DIRECTORY_SEPARATOR . $file) ) {
                include_once( $dir . DIRECTORY_SEPARATOR . $file );
            }
        }
        closedir( $dh );
     }

// then a function for getting them:
function spip_get_site($query) {
  foreach ($GLOBALS['spip_sites'] as $name => $hosts) {
     foreach ($hosts as $def_host) {
       if (preg_match('/' . $def_host . '/',$query) >= 1) { return $name; }
     }
  }

  // If not matched, return default
  return 'default';

}

?>