PageRenderTime 1578ms CodeModel.GetById 1562ms RepoModel.GetById 1ms app.codeStats 0ms

/silversupport/php/functions.php

https://bitbucket.org/ianb/silverlining/
PHP | 38 lines | 33 code | 3 blank | 2 comment | 8 complexity | 44d93facf5ad5d7f9ad91590ea72839e MD5 | raw file
Possible License(s): GPL-2.0
  1. <?
  2. function silver_next_path($default=NULL, $url_path=NULL) {
  3. global $silver_base, $silver_php_root;
  4. if (! $url_path) {
  5. $url_path = $_SERVER['SCRIPT_NAME'];
  6. }
  7. $path = "{$silver_base}/{$silver_php_root}/{$url_path}";
  8. if (is_dir($path) and file_exists(rtrim($path, '/') . '/index.php')) {
  9. if (rtrim($path, '/') == $path) {
  10. # We need a redirect
  11. header("Status: 301 Moved Permanently");
  12. header("Location: {$url_path}/");
  13. exit();
  14. }
  15. $path = rtrim($path, '/') . '/index.php';
  16. }
  17. if (! file_exists($path)) {
  18. if ($default) {
  19. /*echo "Path '{$path}' (in '{$silver_php_root}') didn't exist<br>\n";*/
  20. $path = $default;
  21. } else {
  22. return NULL;
  23. }
  24. }
  25. return $path;
  26. }
  27. function silver_call_next($default=NULL, $url_path=NULL) {
  28. $path = silver_next_path($default, $url_path);
  29. if ($path) {
  30. chdir(dirname($path));
  31. }
  32. $_SERVER['PHP_SELF'] = $path;
  33. return $path;
  34. }
  35. ?>