changeset 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 e1cfbfb0b64a
children 4a95cd4fa341
files admajax.js.php pages/vote.inc.php usrajax.js.php
diffstat 3 files changed, 26 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.js.php	Wed Jan 25 22:02:29 2017 +0200
+++ b/admajax.js.php	Wed Jan 25 22:39:42 2017 +0200
@@ -13,11 +13,7 @@
 
 // Initiate SQL database connection
 if (!stConnectSQLDB())
-{
-  // Error occured, bail out early
-  cmPrintPageFooter();
   exit;
-}
 
 // Fetch non-"hardcoded" settings from SQL database
 stReloadSettings();
--- a/pages/vote.inc.php	Wed Jan 25 22:02:29 2017 +0200
+++ b/pages/vote.inc.php	Wed Jan 25 22:39:42 2017 +0200
@@ -80,24 +80,7 @@
 <noscript>
 <div class="notice">If your browser supports JavaScript, enable it for smoother voting experience.</div>
 </noscript>
-<script type="text/javascript">
-
-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;
-}
-
-</script>
+<script type="text/javascript" src="usrajax.js.php"></script>
 <?php
   // Try fetching previously stored votes
   $sql = stPrepareSQL(
--- 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;
+}