srkSend((object) array('res' => 'successful')); } else { srkSend((object) array('res' => 'Failed to write data')); } } } elseif ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'logout') { unset($_SESSION['userId']); srkSend((object) array('res' => 'successful')); } elseif ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'edit') { $user = new UserData(); $user->readUser($_SESSION['userId']); srkSend($user->update($_POST)); } } elseif ($srkEnv->reqURLLength == 2 && $srkEnv->reqURL[2] == 'github') { require_once $srkEnv->appPath . '/modules/thirdpartylogin/github.php'; $loginRes = GithubLogin::fetchInfo(); if ($loginRes) { srkRender('error', array('error' => array('status' => -1, 'stack' => $loginRes))); } else { header("Location: /"); } } elseif ($srkEnv->reqURLLength >= 2 && $srkEnv->reqURL[2] == 'query') { if ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'whoami') { $userId = $_SESSION['userId']; if (!isset($userId)) { srkSend((object) array('error' => 'not logged in')); } else { srkSend((object) array('userId' => $userId)); } } elseif ($srkEnv->reqURLLength == 4 && $srkEnv->reqURL[4] == 'avatarurl') { $user = new UserData();