summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-06-19 06:32:23 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-06-19 06:32:23 +0000
commitcef43c3602c38fe4b49e74bdfa429c66929ada0e (patch)
tree0eaf81ca59c5c52ff023254105afb9f43b67cfc5 /lib
parentcabbf907970a6d514a4b9288abcfec3c0c6b2d55 (diff)
downloadampache-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')
-rw-r--r--lib/class/core.class.php51
-rw-r--r--lib/ui.lib.php2
2 files changed, 52 insertions, 1 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
?>
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 68f92a50..1c2c480e 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -35,7 +35,7 @@
* $text The details of the message
* $cancel T/F show a cancel button that uses return_referrer()
*/
-function show_confirmation($title,$text,$next_url,$cancel=0) {
+function show_confirmation($title,$text,$next_url,$cancel=0,$form_name='confirmation') {
if (substr_count($next_url,Config::get('web_path'))) {
$path = $next_url;