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(); $user->readUser($srkEnv->reqURL[3]); if ($user->getField('source') == 'local') {
if ($srkEnv->uiType == '/ban') { require_once $srkEnv->appPath . '/modules/render.php'; srkRender('home', array()); return; } // load content profiles require_once './config/content.php'; // start session session_start(); // decide which route to use if ($srkEnv->reqURLLength == 0 || $srkEnv->reqURLLength == 1 && $srkEnv->reqURL[1] == 'home') { // render homepage require_once $srkEnv->appPath . '/routes/home.php'; } else { $routeList = array('list', 'view', 'pen', 'comment', 'resources', 'login', 'admin'); foreach ($routeList as $route) { if ($srkEnv->reqURL[1] == $route) { require_once $srkEnv->appPath . '/routes/' . $route . '.php'; break; } } } if (!isset($srkEnv->sent)) { require_once $srkEnv->appPath . '/modules/render.php'; if ($srkEnv->reqMethod == 'GET') { require_once $srkEnv->appPath . '/modules/render.php'; srkRender('error', array('error' => array('status' => '404', 'stack' => 'Unused url'))); } else { srkSend((object) array('error' => 'Unused url')); } }
if ($authRes) { srkSend((object) array('error' => $authRes)); return; } } 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'));
<?php if (!defined('srkVersion')) { exit(403); } if ($srkEnv->reqURLLength == 2) { $penId = $srkEnv->reqURL[2]; $srkEnv->pageTitle .= '.view ' . $penId; require_once $srkEnv->appPath . '/modules/render.php'; srkRender('view', array('penid' => $penId)); if (is_file($srkEnv->penPath . '/' . $penId . '/content.md')) { require_once $srkEnv->appPath . '/modules/db.php'; srkVisitCountUpdate($penId); } }
<?php if (!defined('srkVersion')) { exit(403); } require_once $srkEnv->appPath . '/modules/db.php'; if ($srkEnv->reqMethod == 'GET') { require_once $srkEnv->appPath . '/modules/render.php'; srkRender('home', array('visitCount' => srkVisitCountGet('shiruku_site_total'))); }
} if ($srkEnv->reqURLLength == 3) { require_once $srkEnv->appPath . '/modules/render.php'; if ($srkEnv->reqURL[2] == 'query') { require_once $srkEnv->appPath . '/modules/file.php'; $resId = $srkEnv->reqURL[3]; if (is_dir($srkEnv->resPath . '/' . $resId)) { $conf = json_decode(getFileContent($srkEnv->resPath . '/' . $resId . '/config.json')); $contentFileName = $srkEnv->resPath . '/' . $resId . '/content'; if ($conf !== -1 && is_file($contentFileName)) { if (isset($conf->contentType)) { header("Content-Type: " . $conf->contentType); } else { header("Content-Type: application/octet-stream"); } if ($conf->noOnline) { if ($conf->fileName) { header('Content-Disposition: attachment; filename=' . basename($conf->fileName)); } else { header('Content-Disposition: attachment; filename=unknownFileName'); } } srkStream($contentFileName); } else { srkRender('error', array('error' => array('status' => -2, 'stack' => 'Resource error'))); } } else { srkRender('error', array('error' => array('status' => 404, 'stack' => 'Resource not found'))); } } }
<?php if (!defined('srkVersion')) { exit(403); } if ($srkEnv->reqMethod == 'GET') { $srkEnv->pageTitle .= '.list'; require_once $srkEnv->appPath . '/modules/render.php'; srkRender('list', array()); }