| [34] | 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 |
|---|
| 10 | function ob_filter_path_nicer($o) |
|---|
| 11 | { |
|---|
| [161] | 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 | } |
|---|
| [34] | 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. |
|---|
| 26 | function 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 | ?> |
|---|