function commentListGenerate() { global $srkEnv; $res = array(); $fileList = getDirCatalog($srkEnv->penPath); foreach ($fileList as $penId) { $penCom = commentLoadAll($penId); foreach ($penCom as $com) { array_push($res, $com); } } $cacheFile = new FileCache(); $cacheFile->load('commentlist.json'); $cacheFile->write(json_encode($res)); return $res; }
function penListGenerate() { global $srkEnv; $res = array(); $list = getDirCatalog($srkEnv->penPath); foreach ($list as $penId) { if (is_file($srkEnv->penPath . '/' . $penId . '/config.json')) { $penConf = penConfigLoad($penId); array_push($res, $penConf); } } $listCache = new FileCache(); $listCache->load('penlist.json'); $listCache->write(json_encode($res)); return $res; }
$res->config = json_encode($srkContent->defaultPenConfig); } srkSend($res); } elseif ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'genid') { $penId = ''; do { $penId = randId(6); } while (is_dir($srkEnv->penPath . '/' . $penId)); srkSend((object) array('id' => $penId)); } } elseif ($srkEnv->reqURL[2] == 'invite') { if (!in_array('invite', $user->getField("accessList"))) { srkSend((object) array('error' => 'Access denied')); } elseif ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'query') { $res = array(); $fileList = getDirCatalog($srkEnv->userPath); foreach ($fileList as $item) { if (substr($item, 0, 7) == 'invite_') { $inviteCode = substr($item, 7, -5); $inviteObj = json_decode(getFileContent($srkEnv->userPath . '/' . $item)); $inviteObj->value = $inviteCode; array_push($res, $inviteObj); } } srkSend((object) array('list' => $res)); } elseif ($srkEnv->reqURLLength == 4 && $srkEnv->reqURL[3] == 'generate') { $count = (int) $srkEnv->reqURL[4]; $defInfo = (object) array('used' => false); if ($count > 0 && $count < 16) { for ($i = 0; $i < $count; ++$i) { $code = '';