diff usrajax.js.php @ 1085:01783161eeb2

Fix usr and adm ajax and voting.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 Jan 2017 22:39:42 +0200
parents 7da8bde9b7be
children
line wrap: on
line diff
--- a/usrajax.js.php	Wed Jan 25 22:02:29 2017 +0200
+++ b/usrajax.js.php	Wed Jan 25 22:39:42 2017 +0200
@@ -5,14 +5,37 @@
 // (C) Copyright 2012-2017 Tecnic Software productions (TNSP)
 //
 $sessionType = "user";
+header("Content-Type: application/javascript");
 require_once "mconfig.inc.php";
 require_once "msite.inc.php";
 require_once "msession.inc.php";
 
 
-if (!stUserSessionAuth() || !stCSRFCheck())
+// Initiate SQL database connection
+if (!stConnectSQLDB())
   exit;
 
+// Fetch non-"hardcoded" settings from SQL database
+stReloadSettings();
+
+stUserSessionAuth();
+
 stCommonAJAX("usrajax.php", "usrlogout.php");
 
-?>
\ No newline at end of file
+
+?>
+
+function updateVote(eid, value)
+{
+  var msuccess = function(txt)
+  {
+  }
+
+  var mfail = function(txt)
+  {
+    jsMessageBox("<h1>Ooops, an error occured</h2><p>Something went wrong, votes might not be submitted. :(</p>");
+  }
+
+  jsSendPOSTRequest("action=set&entry_id="+eid+"&vote="+value, msuccess, mfail);
+  return false;
+}