diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-06-19 06:32:23 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-06-19 06:32:23 +0000 |
commit | cef43c3602c38fe4b49e74bdfa429c66929ada0e (patch) | |
tree | 0eaf81ca59c5c52ff023254105afb9f43b67cfc5 /lib/class | |
parent | cabbf907970a6d514a4b9288abcfec3c0c6b2d55 (diff) | |
download | ampache-cef43c3602c38fe4b49e74bdfa429c66929ada0e.tar.gz ampache-cef43c3602c38fe4b49e74bdfa429c66929ada0e.tar.bz2 ampache-cef43c3602c38fe4b49e74bdfa429c66929ada0e.zip |
reorganize the menu a whole bunch and add a confirmation page to the catalog deletion
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/core.class.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/class/core.class.php b/lib/class/core.class.php index bd0e422d..4818e39b 100644 --- a/lib/class/core.class.php +++ b/lib/class/core.class.php @@ -36,5 +36,56 @@ class Core { } // construction + /** + * form_register + * This registers a form with a SID, inserts it into the session variables + * and then returns a string for use in the HTML form + */ + public static function form_register($name) { + + // Make ourselves a nice little sid + $sid = md5(uniqid(rand(), true)); + + // Register it + $_SESSION['forms'][$name] = array('sid'=>$sid,'expire'=>time() + Config::get('session_length')); + + $string = '<input type="hidden" name="form_validation" value="' . $sid . '" />'; + + return $string; + + } // form_register + + /** + * form_verify + * This takes a form name and then compares it with the posted sid, if they don't match + * then it returns false and doesn't let the person continue + */ + public static function form_verify($name,$method='post') { + + switch ($method) { + case 'post': + $source = $_POST['form_validation']; + break; + case 'get': + $source = $_GET['form_validation']; + break; + case 'cookie': + $source = $_COOKIE['form_validation']; + break; + case 'request': + $source = $_REQUEST['form_validation']; + break; + } + + if ($source == $_SESSION['forms'][$name]['sid'] AND $_SESSION['forms'][$name]['expire'] > time()) { + unset($_SESSION['forms'][$name]); + return true; + } + + unset($_SESSION['forms'][$name]); + return false; + + } // form_verify + } // Core ?> |