} 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(); $user->readUser($srkEnv->reqURL[3]); if ($user->getField('source') == 'local') { $resURL = 'http://cn.gravatar.com/avatar/' . md5($user->getField('email')) . '?s=100&d=mm&r=g'; } else { $resURL = $user->getField('avatarURL'); } srkSend((object) array('url' => $resURL)); } elseif ($srkEnv->reqURLLength == 4) { $user = new UserData(); $user->readUser($srkEnv->reqURL[3]); srkSend((object) array('data' => $user->getField($srkEnv->reqURL[4]))); } }
} } else { $user->readUser($_SESSION['userId']); } if ($user->status != 'normal') { if ($srkEnv->reqMethod == 'GET') { srkRender('error', array('error' => array('status' => '403', 'stack' => 'Access denied'))); } else { srkSend((object) array('error' => 'Access denied')); } return; } elseif ($srkEnv->reqMethod == 'GET') { srkRender('admin', array()); } elseif ($srkEnv->reqURL[2] == 'query') { if ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'access') { $access = $user->getField('accessList'); if (isset($access)) { $res = array(); if (in_array('pen', $access)) { array_push($res, 'penlist'); array_push($res, 'penedit'); } if (in_array('invite', $access)) { array_push($res, 'invite'); } srkSend((object) array('error' => false, 'accessList' => $res)); } else { srkSend((object) array('error' => 'Access denied')); } } } elseif ($srkEnv->reqURL[2] == 'pen') {