Ejemplo n.º 1
0
/**
 * スレを殿堂入りにセットする関数
 *
 * $set は、0(解除), 1(追加), top, up, down, bottom
 *
 * @access  public
 * @return  boolean
 */
function setPalace($host, $bbs, $key, $set)
{
    global $_conf;
    $idxfile = P2Util::getKeyIdxFilePath($host, $bbs, $key);
    // 既に key.idx データがあるなら読み込む
    if (file_exists($idxfile) and $lines = file($idxfile)) {
        $l = rtrim($lines[0]);
        $data = explode('<>', $l);
    }
    if (false === FileCtl::make_datafile($_conf['palace_file'], $_conf['palace_perm'])) {
        return false;
    }
    if (false === ($pallines = file($_conf['palace_file']))) {
        return false;
    }
    $newlines = array();
    $before_line_num = 0;
    // {{{ 最初に重複要素を削除しておく
    if (!empty($pallines)) {
        $i = -1;
        foreach ($pallines as $l) {
            $i++;
            $l = rtrim($l);
            $lar = explode('<>', $l);
            // 重複回避
            if ($lar[1] == $key && $lar[11] == $bbs) {
                $before_line_num = $i;
                // 移動前の行番号をセット
                continue;
                // keyのないものは不正データなのでスキップ
            } elseif (!$lar[1]) {
                continue;
            } else {
                $newlines[] = $l;
            }
        }
    }
    // }}}
    if (!empty($GLOBALS['brazil'])) {
        //$newlines = _removeLargePallistData($newlines);
    }
    // 新規データ設定
    if ($set) {
        $newdata = implode('<>', array(geti($data[0]), $key, geti($data[2]), geti($data[3]), geti($data[4]), geti($data[5]), geti($data[6]), geti($data[7]), geti($data[8]), geti($data[9]), $host, $bbs));
        require_once P2_LIB_DIR . '/getSetPosLines.func.php';
        $rec_lines = getSetPosLines($newlines, $newdata, $before_line_num, $set);
    } else {
        $rec_lines = $newlines;
    }
    if (false === FileCtl::filePutRename($_conf['palace_file'], $rec_lines ? implode("\n", $rec_lines) . "\n" : '')) {
        trigger_error(sprintf('p2 error: %s(), FileCtl::filePutRename() failed.', __FUNCTION__), E_USER_WARNING);
        return false;
    }
    return true;
}
Ejemplo n.º 2
0
/**
 * @access  private
 * @return  array  読み込んだkeyデータ
 */
function _setFavToKeyIdx($host, $bbs, $key, $setfav)
{
    $idxfile = P2Util::getKeyIdxFilePath($host, $bbs, $key);
    // FileCtl::mkdirFor($idxfile);
    $data = array();
    // 既にidxデータがあるなら読み込む
    if (file_exists($idxfile) and $lines = file($idxfile)) {
        $l = rtrim($lines[0]);
        $data = explode('<>', $l);
    }
    // スレッド.idx 記録
    if ($setfav == '0' || $setfav == '1') {
        // お気にスレから外した結果、idxの意味がなくなれば削除する
        if ($setfav == '0' and empty($data[3]) && empty($data[4]) && geti($data[9]) <= 1) {
            @unlink($idxfile);
        } else {
            P2Util::recKeyIdx($idxfile, array(geti($data[0]), $key, geti($data[2]), geti($data[3]), geti($data[4]), geti($data[5]), $setfav, geti($data[7]), geti($data[8]), geti($data[9]), $host, $bbs, geti($data[12])));
        }
    }
    return $data;
}
Ejemplo n.º 3
0
Archivo: Thread.php Proyecto: poppen/p2
 /**
  * Set Path info
  *
  * @access  public
  * @return  void
  */
 function setThreadPathInfo($host, $bbs, $key)
 {
     $GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('setThreadPathInfo()');
     if (preg_match('/[<>]/', $host) || preg_match('/[<>]/', $bbs) || preg_match('/[<>]/', $key)) {
         trigger_error(__FUNCTION__, E_USER_WARNING);
         die('Error: ' . __FUNCTION__);
     }
     $this->host = $host;
     $this->bbs = $bbs;
     $this->key = $key;
     $this->keydat = P2Util::datDirOfHostBbs($this->host, $this->bbs) . $this->key . '.dat';
     $this->keyidx = P2Util::getKeyIdxFilePath($this->host, $this->bbs, $this->key);
     $GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('setThreadPathInfo()');
 }
Ejemplo n.º 4
0
Archivo: post.php Proyecto: poppen/p2
/**
 * key.idxに名前とメールを保存する
 *
 * @return  void
 */
function _recKeyIdx($host, $bbs, $key, $tagCsvF)
{
    if (!($host && $bbs && $key)) {
        return;
    }
    $keyidx = P2Util::getKeyIdxFilePath($host, $bbs, $key);
    $akeyline = array();
    if (file_exists($keyidx) and $keylines = file($keyidx)) {
        $akeyline = explode('<>', rtrim($keylines[0]));
    }
    $sar = array($akeyline[0], $akeyline[1], $akeyline[2], $akeyline[3], $akeyline[4], $akeyline[5], $akeyline[6], $tagCsvF['FROM'], $tagCsvF['mail'], $akeyline[9], $akeyline[10], $akeyline[11], $akeyline[12]);
    P2Util::recKeyIdx($keyidx, $sar);
}
Ejemplo n.º 5
0
$bbs = geti($_GET['bbs']);
$key = geti($_GET['key']);
$rescount = (int) geti($_GET['rescount'], 1);
$popup = (int) geti($_GET['popup'], 0);
if (!($itaj = P2Util::getItaName($host, $bbs))) {
    $itaj = $bbs;
}
$ttitle_en = isset($_GET['ttitle_en']) ? $_GET['ttitle_en'] : '';
$ttitle_hs = null;
if (strlen($ttitle_en)) {
    $ttitle_hs = hs(P2Util::htmlEntityDecodeLite(base64_decode($ttitle_en)));
}
if (P2Validate::host($host) || $bbs && P2Validate::bbs($bbs) || $key && P2Validate::key($key)) {
    p2die('不正な引数です');
}
$keyidx = P2Util::getKeyIdxFilePath($host, $bbs, $key);
// フォームのオプション読み込み
require_once P2_LIB_DIR . '/post_options_loader.inc.php';
// 表示指定
$class_ttitle = '';
$target_read = '';
$sub_size_at = '';
if (!$_conf['ktai']) {
    $class_ttitle = ' class="thre_title"';
    $target_read = ' target="read"';
    $sub_size_at = ' size="40"';
}
// {{{ スレ立てなら
if (!empty($_GET['newthread'])) {
    //$ptitle = "{$itaj} - 新規スレッド作成";
    $ptitle = "新規スレッド作成";
Ejemplo n.º 6
0
/**
 * スレッドあぼーんをオンオフする関数
 *
 * $set は、0(解除), 1(追加), 2(トグル)
 *
 * @access  public
 * @return  boolean  実行成否
 */
function settaborn($host, $bbs, $key, $set)
{
    global $_conf, $title_msg, $info_msg;
    // {{{ key.idx 読み込む
    $idxfile = P2Util::getKeyIdxFilePath($host, $bbs, $key);
    $data[0] = null;
    // データがあるなら読み込む
    if (file_exists($idxfile)) {
        $lines = file($idxfile);
        $l = rtrim($lines[0]);
        $data = explode('<>', $l);
    }
    // }}}
    // p2_threads_aborn.idx のパス取得
    $taborn_idx = P2Util::getThreadAbornFile($host, $bbs);
    if (false === FileCtl::make_datafile($taborn_idx, $_conf['p2_perm'])) {
        return false;
    }
    if (false === ($taborn_lines = file($taborn_idx))) {
        return false;
    }
    $newlines = array();
    $aborn_attayo = false;
    $title_msg_pre = '';
    $info_msg_pre = '';
    if ($taborn_lines) {
        foreach ($taborn_lines as $line) {
            $line = rtrim($line);
            $lar = explode('<>', $line);
            if ($lar[1] == $key) {
                $aborn_attayo = true;
                // 既にあぼーん中である
                if ($set == 0 or $set == 2) {
                    $title_msg_pre = "+ あぼーん 解除しますた";
                    $info_msg_pre = "+ あぼーん 解除しますた";
                }
                continue;
            }
            if (!$lar[1]) {
                continue;
            }
            // keyのないものは不正データ
            $newlines[] = $line;
        }
    }
    // 新規データ追加
    if ($set == 1 or !$aborn_attayo && $set == 2) {
        $newdata = "{$data['0']}<>{$key}<><><><><><><><>";
        $newlines ? array_unshift($newlines, $newdata) : ($newlines = array($newdata));
        $title_msg_pre = "○ あぼーん しますた";
        $info_msg_pre = "○ あぼーん しますた";
    }
    // 書き込む
    $cont = '';
    if ($newlines) {
        foreach ($newlines as $l) {
            $cont .= $l . "\n";
        }
    }
    if (false === file_put_contents($taborn_idx, $cont, LOCK_EX)) {
        p2die('cannot write file.');
        return false;
    }
    $GLOBALS['title_msg'] = $title_msg_pre;
    $GLOBALS['info_msg'] = $info_msg_pre;
    return true;
}