path = $conf['tmpdir'] . '/captcha/' . date('Y-m-d') . '/' . md5($ident . $rand) . '.cookie'; io_makeFileDir($this->path); } /** * Creates a one time captcha cookie */ public function set() { touch($this->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); } } }