Skip to content

Instantly share code, notes, and snippets.

@psolru
Created October 24, 2019 15:29
Show Gist options
  • Save psolru/f392a407a9c6e4c4d9e47407e6d97332 to your computer and use it in GitHub Desktop.
Save psolru/f392a407a9c6e4c4d9e47407e6d97332 to your computer and use it in GitHub Desktop.
creating temp-directory - i use it as a starter in the whisker menu under xubuntu
#!/usr/bin/php
<?php
function tempName($ext='') {
$chars = 'qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM1234567890';
$cl = strlen($chars);
$l = 30;
do {
$o = '';
while (strlen($o)<$l)
$o .= substr($chars, mt_rand(0,$cl), 1);
$file = $o.$ext;
} while (file_exists($file));
return $file;
}
$tmpDir = tempName();
shell_exec('mkdir ~/.temp/'.$tmpDir);
shell_exec('nemo ~/.temp/'.$tmpDir);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment