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