path); } /** * Checks if the captcha cookie exists and deletes it * * @return bool true if the cookie existed */ public function check() { if (file_exists($this->path)) { unlink($this->path); return true; } return false; } /** * remove all outdated captcha cookies */ public static function clean() { global $conf; $path = $conf['tmpdir'] . '/captcha/'; $dirs = glob("$path/*", GLOB_ONLYDIR); $today = date('Y-m-d'); foreach ($dirs as $dir) { if (basename($dir) === $today) continue; if (!preg_match('/\/captcha\//', $dir)) continue; // safety net io_rmdir($dir, true); } } }