} else { $pos = strpos($content, "\n"); if (!$pos) { $pos = strpos($content, "\r\n"); } if ($pos != false) { $content = substr($content, 0, $pos); $content .= "<br/>..."; } } srkSend(array('content' => $content, 'penId' => $penId)); } elseif ($srkEnv->reqURL[3] == 'config') { $config = penConfigLoad($penId); srkSend($config); } elseif ($srkEnv->reqURL[3] == 'neighbor') { $config = penConfigLoad($penId); $prev = (object) array('priority' => -0x7fffffff); $succ = (object) array('priority' => 0x7ffffffe); $penList = penListGet(); foreach ($penList as $content) { if ($content->priority < $config->priority && $content->priority > $prev->priority) { $prev = $content; } if ($content->priority > $config->priority && $content->priority < $succ->priority) { $succ = $content; } } srkSend((object) array('prev' => $prev->penId, 'succ' => $succ->penId)); } } } elseif ($srkEnv->reqURL[2] == 'like' && $srkEnv->reqMethod == 'POST') {
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; }