Index: /trunk/comments.php
===================================================================
--- /trunk/comments.php	(revision 2756)
+++ /trunk/comments.php	(revision 2757)
@@ -66,5 +66,5 @@
 $page['sort_by'] = 'date';
 // if the form was submitted, it overloads default behaviour
-if (isset($_GET['sort_by']))
+if (isset($_GET['sort_by']) and isset($sort_by[$_GET['sort_by']]) )
 {
   $page['sort_by'] = $_GET['sort_by'];
@@ -75,5 +75,5 @@
 $page['sort_order'] = 'DESC';
 // if the form was submitted, it overloads default behaviour
-if (isset($_GET['sort_order']))
+if (isset($_GET['sort_order']) and isset($sort_order[$_GET['sort_order']]))
 {
   $page['sort_order'] = $_GET['sort_order'];
Index: /trunk/include/functions_session.inc.php
===================================================================
--- /trunk/include/functions_session.inc.php	(revision 2756)
+++ /trunk/include/functions_session.inc.php	(revision 2757)
@@ -67,4 +67,5 @@
     ini_set('session.use_only_cookies', $conf['session_use_only_cookies']);
     ini_set('session.use_trans_sid', intval($conf['session_use_trans_sid']));
+    ini_set('session.cookie_httponly', 1);
   }
   session_name($conf['session_name']);
Index: /trunk/include/functions_user.inc.php
===================================================================
--- /trunk/include/functions_user.inc.php	(revision 2756)
+++ /trunk/include/functions_user.inc.php	(revision 2757)
@@ -1014,14 +1014,26 @@
     {
       $cookie = $user_id.'-'.$now.'-'.$key;
-      setcookie($conf['remember_me_name'],
+      if (version_compare(PHP_VERSION, '5.2', '>=') )
+      {
+        setcookie($conf['remember_me_name'],
             $cookie,
             time()+$conf['remember_me_length'],
-            cookie_path()
+            cookie_path(),ini_get('session.cookie_domain'),ini_get('session.cookie_secure'),
+            ini_get('session.cookie_httponly')
           );
+      }
+      else
+      {
+        setcookie($conf['remember_me_name'],
+            $cookie,
+            time()+$conf['remember_me_length'],
+            cookie_path(),ini_get('session.cookie_domain'),ini_get('session.cookie_secure')
+          );
+      }
     }
   }
   else
   { // make sure we clean any remember me ...
-    setcookie($conf['remember_me_name'], '', 0, cookie_path());
+    setcookie($conf['remember_me_name'], '', 0, cookie_path(),ini_get('session.cookie_domain'));
   }
   if ( session_id()!="" )
@@ -1063,5 +1075,5 @@
       }
     }
-    setcookie($conf['remember_me_name'], '', 0, cookie_path());
+    setcookie($conf['remember_me_name'], '', 0, cookie_path(),ini_get('session.cookie_domain'));
   }
   return false;
@@ -1091,4 +1103,18 @@
   trigger_action('login_failure', $username);
   return false;
+}
+
+/** Performs all the cleanup on user logout */
+function logout_user()
+{
+  global $conf;
+  $_SESSION = array();
+  session_unset();
+  session_destroy();
+  setcookie(session_name(),'',0,
+      ini_get('session.cookie_path'),
+      ini_get('session.cookie_domain')
+    );
+  setcookie($conf['remember_me_name'], '', 0, cookie_path(),ini_get('session.cookie_domain'));
 }
 
Index: /trunk/include/user.inc.php
===================================================================
--- /trunk/include/user.inc.php	(revision 2756)
+++ /trunk/include/user.inc.php	(revision 2757)
@@ -30,12 +30,5 @@
   if (isset($_GET['act']) and $_GET['act'] == 'logout')
   { // logout
-    $_SESSION = array();
-    session_unset();
-    session_destroy();
-    setcookie(session_name(),'',0,
-        ini_get('session.cookie_path'),
-        ini_get('session.cookie_domain')
-      );
-    setcookie($conf['remember_me_name'], '', 0, cookie_path());
+    logout_user();
     redirect(make_index_url());
   }
Index: /trunk/include/ws_functions.inc.php
===================================================================
--- /trunk/include/ws_functions.inc.php	(revision 2756)
+++ /trunk/include/ws_functions.inc.php	(revision 2757)
@@ -1188,15 +1188,7 @@
 function ws_session_logout($params, &$service)
 {
-  global $user, $conf;
   if (!is_a_guest())
   {
-    $_SESSION = array();
-    session_unset();
-    session_destroy();
-    setcookie(session_name(),'',0,
-        ini_get('session.cookie_path'),
-        ini_get('session.cookie_domain')
-      );
-    setcookie($conf['remember_me_name'], '', 0, cookie_path());
+    logout_user();
   }
   return true;
@@ -1436,5 +1428,5 @@
 
   invalidate_user_cache();
-  
+
   return $creation_output;
 }
@@ -1474,5 +1466,5 @@
     PREG_SPLIT_NO_EMPTY
     );
-  
+
   $query = '
 SELECT
@@ -1480,10 +1472,10 @@
     md5sum
   FROM '.IMAGES_TABLE.'
-  WHERE md5sum IN (\''.implode("','", $md5sums).'\')  
+  WHERE md5sum IN (\''.implode("','", $md5sums).'\')
 ;';
   $id_of_md5 = simple_hash_from_query($query, 'md5sum', 'id');
 
   $result = array();
-  
+
   foreach ($md5sums as $md5sum)
   {
Index: /trunk/plugins/event_tracer/event_list.php
===================================================================
--- /trunk/plugins/event_tracer/event_list.php	(revision 2756)
+++ /trunk/plugins/event_tracer/event_list.php	(revision 2757)
@@ -17,5 +17,5 @@
           {
             $files = array_merge($files, get_php_files($path.'/'.$node, $to_ignore));
-            
+
           }
           if ( is_file($path.'/'.$node) )
@@ -44,5 +44,5 @@
   $code = preg_replace( '#\/\*.*\*\/#m', '', $code);
   $code = preg_replace( '#\/\/.*#', '', $code);
-  
+
   $count = preg_match_all(
     '#[^a-zA-Z_$-]trigger_(action|event)\s*\(\s*([^,)]+)#m',
@@ -58,5 +58,5 @@
 }
 
-$sort= isset($_GET['sort']) ? $_GET['sort'] : 1;
+$sort= isset($_GET['sort']) ? (int)$_GET['sort'] : 1;
 usort(
   $events,
