Skip to content

Commit

Permalink
Made some hardcoded tmp paths dynamic by using sys_get_temp_dir. If f…
Browse files Browse the repository at this point in the history
…unction is not available the old mechanisms are used.
  • Loading branch information
PhilippSoehnlein committed Jan 16, 2011
1 parent c78da98 commit d088a90
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
23 changes: 14 additions & 9 deletions Tests/Auth/OpenID/StoreTest.php
Expand Up @@ -23,15 +23,20 @@

function _Auth_OpenID_mkdtemp()
{
if (strpos(PHP_OS, 'WIN') === 0) {
$dir = $_ENV['TMP'];
if (!isset($dir)) {
$dir = 'C:\Windows\Temp';
}
} else {
$dir = @$_ENV['TMPDIR'];
if (!isset($dir)) {
$dir = '/tmp';
if (function_exists('sys_get_temp_dir')) {
$dir = sys_get_temp_dir();
}
else {
if (strpos(PHP_OS, 'WIN') === 0) {
$dir = $_ENV['TMP'];
if (!isset($dir)) {
$dir = 'C:\Windows\Temp';
}
} else {
$dir = @$_ENV['TMPDIR'];
if (!isset($dir)) {
$dir = '/tmp';
}
}
}

Expand Down
20 changes: 19 additions & 1 deletion examples/consumer/common.php
Expand Up @@ -50,7 +50,25 @@ function &getStore() {
* created elsewhere. After you're done playing with the example
* script, you'll have to remove this directory manually.
*/
$store_path = "/tmp/_php_consumer_test";
$store_path = null;
if (function_exists('sys_get_temp_dir')) {
$store_path = sys_get_temp_dir();
}
else {
if (strpos(PHP_OS, 'WIN') === 0) {
$store_path = $_ENV['TMP'];
if (!isset($store_path)) {
$dir = 'C:\Windows\Temp';
}
}
else {
$store_path = @$_ENV['TMPDIR'];
if (!isset($store_path)) {
$store_path = '/tmp';
}
}
}
$store_path .= DIRECTORY_SEPARATOR . '_php_consumer_test';

if (!file_exists($store_path) &&
!mkdir($store_path)) {
Expand Down

0 comments on commit d088a90

Please sign in to comment.