/** * hostとbbsから板名を返す */ public static function getItaName($host, $bbs) { global $_conf; $id = $host . '/' . $bbs; if (array_key_exists($id, self::$_itaNames)) { return self::$_itaNames[$id]; } $p2_setting_txt = self::idxDirOfHostBbs($host, $bbs) . 'p2_setting.txt'; if (file_exists($p2_setting_txt)) { $p2_setting_cont = FileCtl::file_read_contents($p2_setting_txt); if ($p2_setting_cont) { $p2_setting = unserialize($p2_setting_cont); if (isset($p2_setting['itaj'])) { self::$_itaNames[$id] = $p2_setting['itaj']; return self::$_itaNames[$id]; } } } // 板名Longの取得 if (!isset($p2_setting['itaj'])) { $itaj = BbsMap::getBbsName($host, $bbs); if ($itaj != $bbs) { self::$_itaNames[$id] = $p2_setting['itaj'] = $itaj; FileCtl::make_datafile($p2_setting_txt, $_conf['p2_perm']); $p2_setting_cont = serialize($p2_setting); if (FileCtl::file_write_contents($p2_setting_txt, $p2_setting_cont) === false) { p2die("{$p2_setting_txt} を更新できませんでした"); } return self::$_itaNames[$id]; } } return null; }
/** * hostとbbsから板名を取得する * * @access public * @return string|null */ function getItaName($host, $bbs) { global $_conf, $ita_names; $id = $host . '/' . $bbs; if (isset($ita_names[$id])) { return $ita_names[$id]; } $p2_setting_txt = P2Util::idxDirOfHostBbs($host, $bbs) . 'p2_setting.txt'; if (file_exists($p2_setting_txt)) { $p2_setting_cont = file_get_contents($p2_setting_txt); if ($p2_setting_cont) { $p2_setting = unserialize($p2_setting_cont); if (isset($p2_setting['itaj'])) { $ita_names[$id] = $p2_setting['itaj']; return $ita_names[$id]; } } } // 板名Longの取得 if (!isset($p2_setting['itaj'])) { require_once P2_LIB_DIR . '/BbsMap.php'; $itaj = BbsMap::getBbsName($host, $bbs); if ($itaj != $bbs) { $ita_names[$id] = $p2_setting['itaj'] = $itaj; FileCtl::make_datafile($p2_setting_txt, $_conf['p2_perm']); $p2_setting_cont = serialize($p2_setting); if (false === FileCtl::filePutRename($p2_setting_txt, $p2_setting_cont)) { die("Error: {$p2_setting_txt} を更新できませんでした"); } return $ita_names[$id]; } } return null; }