Concrete5 Automatically Logging me out once I access specific part of my block
Permalink
In my block I'm making, it automatically logs me out once I call this php function (or it might be the javascript function, I'm not quite sure). But the other parts of the forum work fine. Its just that once I access a thread it logs the current user out. :P
Here is the code for the php part:
Here is the javascript part:
I've tried to figure out why it does this, heck, I've even done this:
but that doesn't even keep the current user logged in. FYI, the actual code was this:
It was calling User::loginByUserID($uID); because in my log file:
CheckedIP and calling login: 1
1 is of course, Super User (this is running on a local installation in XAMPP)
Here is the code for the php part:
function get_thread($threadID, $incrementViews, $uID) { $db = Loader::db(); $th = Loader::helper('text'); require_once("nbbc.php"); if ($incrementViews == true) { $query = "update btForumPosts set views = views + 1 where postID = ".intval($threadID); $db->query($query); } $q = "select postID, categoryID, uID, bID, postTopic, threadID, postContents, views, ipAddress, timestamp from btForumPosts where threadID = ".$threadID." order by timestamp asc"; $posts_inthread = $db->query($q); $q = "select postID, categoryID, uID, bID, postTopic, threadID, postContents, views, ipAddress, timestamp from btForumPosts where postID = ".$threadID." order by timestamp asc"; $thread_main_post = $db->query($q); $bbcode = new BBCode; $bbcode->SetSmileyURL(DIR_REL."/blocks/discussion_forum/smileys");
Viewing 15 lines of 66 lines. View entire code block.
Here is the javascript part:
function loadThread(threadID, categoryName, categoryID) { try { console.log("Function: loadThread\n"); console.log("ThreadID: " + threadID + "\n"); console.log("CategoryName: " + categoryName + "\n"); console.log("CategoryID: " + categoryID + "\n"); } catch (e) { } $.ajax({ type: "POST", url: "<?= str_replace("&","&",$this->action('get_thread')) ?>", data: "threadID=" + threadID + "&uID=" + userID, dataType: 'json', success: function(thread) { if (thread.posts.length > 0) {
Viewing 15 lines of 41 lines. View entire code block.
I've tried to figure out why it does this, heck, I've even done this:
User::loginByUserID($uID);
but that doesn't even keep the current user logged in. FYI, the actual code was this:
if ($this->checkUserIP($uID, $_SERVER['REMOTE_ADDR'])) { fwrite($this->debugLog, "\nCheckedIP and calling login: ".$uID."\n"); User::loginByUserID($uID); }
It was calling User::loginByUserID($uID); because in my log file:
CheckedIP and calling login: 1
1 is of course, Super User (this is running on a local installation in XAMPP)
FYI, I can post the complete block but I'd rather not have to.
just a note, when you use $this->action('get_thread') it will trigger action_get_thread
Umm... I just set it up to write to the log file each time the method is called.
doesn't call the method. Its only called once. If your referring to it calling it via ajax. Yes, I want it to do that. Otherwise how would I get the thread's contents?
$this->action('get_thread')
doesn't call the method. Its only called once. If your referring to it calling it via ajax. Yes, I want it to do that. Otherwise how would I get the thread's contents?