private static function getTempDir()
 {
     if (!self::$tmpDirCache) {
         $dirs = self::getPotentialTempDirs();
         $finalDir = 'notmp';
         wfUtils::errorsOff();
         foreach ($dirs as $dir) {
             $dir = rtrim($dir, '/') . '/';
             $fh = @fopen($dir . 'wftmptest.txt', 'w');
             if (!$fh) {
                 continue;
             }
             $bytes = @fwrite($fh, 'test');
             if ($bytes != 4) {
                 @fclose($fh);
                 continue;
             }
             @fclose($fh);
             if (!@unlink($dir . 'wftmptest.txt')) {
                 continue;
             }
             $finalDir = $dir;
             break;
         }
         wfUtils::errorsOn();
         self::$tmpDirCache = $finalDir;
     }
     if (self::$tmpDirCache == 'notmp') {
         return false;
     } else {
         return self::$tmpDirCache;
     }
 }
示例#2
0
 private static function getTempDir()
 {
     if (!self::$tmpDirCache) {
         $dirs = array(wfUtils::getPluginBaseDir() . 'wordfence/tmp/', sys_get_temp_dir(), ABSPATH . 'wp-content/uploads/');
         $finalDir = 'notmp';
         wfUtils::errorsOff();
         foreach ($dirs as $dir) {
             $dir = rtrim($dir, '/') . '/';
             $fh = @fopen($dir . 'wftmptest.txt', 'w');
             if (!$fh) {
                 continue;
             }
             $bytes = @fwrite($fh, 'test');
             if ($bytes != 4) {
                 @fclose($fh);
                 continue;
             }
             @fclose($fh);
             if (!@unlink($dir . 'wftmptest.txt')) {
                 continue;
             }
             $finalDir = $dir;
             break;
         }
         wfUtils::errorsOn();
         self::$tmpDirCache = $finalDir;
     }
     if (self::$tmpDirCache == 'notmp') {
         return false;
     } else {
         return self::$tmpDirCache;
     }
 }