function _isWritable($path) { if ($path[strlen($path) - 1] == '/') { return _isWritable($path . uniqid(mt_rand()) . '.tmp'); } if (file_exists($path)) { if (!($f = @fopen($path, 'r+'))) { return false; } fclose($f); return true; } if (!($f = @fopen($path, 'w'))) { return false; } fclose($f); unlink($path); return true; }
function _checkCacheDir($path, $template, $classCounter) { $permError = 0; // special test to see if existing cache files exist and are writable... if ($dh = @opendir($path)) { while (($file = readdir($dh)) !== false) { if ($file == '.' || $file == '..' || $file == '.svn') { continue; } if (is_dir($path . $file)) { $rc = _checkCacheDir($path . $file . '/', $template, $classCounter); if ($rc > 0) { $permError = 1; } } else { $ok = _isWritable($path . $file); if (!$ok) { $template->set_var('location', $path . $file); $template->set_var('status', $ok ? '<span class="yes">OK</span>' : '<span class="notwriteable">NOT WRITABLE</span>'); $template->set_var('rowclass', $classCounter % 2 + 1); $classCounter++; $template->parse('perm', 'perms', true); if (!$ok) { $permError = 1; } } } } closedir($dh); } return $permError; }
function _checkCacheDir($path, &$data_arr) { global $LANG_ENVCHECK; $permError = 0; // special test to see if existing cache files exist and are writable... if ($dh = @opendir($path)) { while (($file = readdir($dh)) !== false) { if ($file == '.' || $file == '..' || $file == '.svn') { continue; } if (is_dir($path . $file)) { $rc = _checkCacheDir($path . $file . '/', $data_arr); if ($rc > 0) { $permError = 1; } } else { $ok = _isWritable($path . $file); if (!$ok) { $data_arr[] = array('location' => $path . $file, 'status' => $ok ? '<span class="yes">OK</span>' : '<span class="notwriteable">' . $LANG_ENVCHECK['not_writable'] . '</span>'); if (!$ok) { $permError = 1; } } } } closedir($dh); } return $permError; }