source: branches/1.0/admin/config.php.example @ 161

Last change on this file since 161 was 161, checked in by moo, 8 years ago

use DIRECTORY_SEPARATOR for windows in config example

File size: 1.4 KB
Line 
1<?php
2
3// this is an example only
4// write your own config and name it as config.php
5
6$charset = "UTF-8";
7
8// this function is detected by xcache.tpl.php, and enabled if function_exists
9// this ob filter is applied for the cache list, not the whole page
10function ob_filter_path_nicer($o)
11{
12    $sep = DIRECTORY_SEPARATOR;
13    $o = str_replace($_SERVER['DOCUMENT_ROOT'],  "{DOCROOT}$sep", $o);
14    $xcachedir = realpath(dirname(__FILE__) . "$sep..$sep");
15    $o = str_replace($xcachedir . $sep, "{XCache}$sep", $o);
16    if ($sep == '/') {
17        $o = str_replace("/home/", "{H}/", $o);
18    }
19    return $o;
20}
21
22// you can simply let xcache to do the http auth
23// but if you have your home made login/permission system, you can implement the following
24// {{{ home made login example
25// this is an example only, it's won't work for you without your implemention.
26function check_admin_and_by_pass_xcache_http_auth()
27{
28    require("/path/to/user-login-and-permission-lib.php");
29    session_start();
30
31    if (!user_logined()) {
32        if (!ask_the_user_to_login()) {
33            exit;
34        }
35    }
36
37    user_load_permissions();
38    if (!user_is_admin()) {
39        die("Permission denied");
40    }
41
42    // user is trusted after permission checks above.
43    // tell XCache about it (the only way to by pass XCache http auth)
44    $_SERVER["PHP_AUTH_USER"] = "moo";
45    $_SERVER["PHP_AUTH_PW"] = "your-xcache-password";
46    return true;
47}
48
49// uncomment:
50// check_admin_and_by_pass_xcache_http_auth();
51// }}}
52
53?>
Note: See TracBrowser for help on using the repository browser.