Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions fetch_dat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -x
DIR=$(cd $(dirname $0); pwd)
cd $DIR

php scripts/fetch-dat.php --mode fav
php scripts/fetch-dat.php --mode recent
php scripts/fetch-dat.php --mode res_hist



10 changes: 10 additions & 0 deletions fetch_subject.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -x
DIR=$(cd $(dirname $0); pwd)
cd $DIR

php scripts/fetch-subject-txt.php --mode fav
php scripts/fetch-subject-txt.php --mode recent
php scripts/fetch-subject-txt.php --mode res_hist



78 changes: 78 additions & 0 deletions rep2/refind2ch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
function refind2ch_search ($query)
{
parse_str($query, $query_arry);

$q = $query_arry['q'];

$base_url = 'https://refind2ch.org';
$endpoint = $base_url . '/module/get_search';
$referer = $base_url . '/search?q=' . urlencode($q);

try {
$req = P2Commun::createHTTPRequest ($endpoint, HTTP_Request2::METHOD_POST);
$req->setHeader('Accept', 'application/json');
$req->setHeader('Referer', $referer);

$req->addPostParameter('q', $q);
$req->addPostParameter('p', 0);
$req->addPostParameter('pink', 0);
$req->addPostParameter('sort', 'false');
$req->addPostParameter('alive', 'true');
$req->addPostParameter('pl', 'false');
$req->addPostParameter('b', 'false');

$response = P2Commun::getHTTPResponse($req);

$code = $response->getStatus();
if ($code != 200) {
p2die("HTTP Error - {$code}");
}

$body = $response->getBody();
} catch (Exception $e) {
p2die($e->getMessage());
}

$threads = json_decode($body, true)['results'];

$result = array();
$boards = array();
$hits = array();
$names = array();

foreach ($threads as $n => $t) {
$host = parse_url($t['url'])['host'];
$bbs = explode('_', $t['board_key'])[1];

$result['threads'][$n] = new stdClass;
$result['threads'][$n]->title = $t['thread_title'];
$result['threads'][$n]->host = $host;
$result['threads'][$n]->bbs = $bbs;
$result['threads'][$n]->tkey = $t['created_at'];
$result['threads'][$n]->resnum = $t['res_num'];
$result['threads'][$n]->ita = $t['board_title'];
$result['threads'][$n]->dayres = $t['res_rate'];

$bkey = md5($host.'-'.$bbs.'-'.$t['board_title']);
if (! isset($boards[$bkey])) {
$board = new stdClass;
$board->host = $host;
$board->bbs = $bbs;
$names[$bkey] = $board->name = $t['board_title'];
$hits[$bkey] = $board->hits = 1;
$boards[$bkey] = $board;
} else {
$hits[$bkey] = ++$boards[$bkey]->hits;
$names[$bkey] = $boards[$bkey]->name;
}
}

$result['modified'] = $response->getHeader('Date');
$result['profile']['regex'] = '/(' . $q .')/i';
$result['profile']['hits'] = count($threads);
array_multisort($hits, SORT_DESC, $names, $boards);
$result['profile']['boards'] = $boards;

return $result;
}
6 changes: 4 additions & 2 deletions rep2/tgrepc.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,10 @@ function tgrep_search($query)
}
return $result;
} else {
require_once './dig2ch.php';
return dig2chsearch($query); // �lj�
// require_once './dig2ch.php';
// return dig2chsearch($query); // �lj�
require_once './refind2ch.php';
return refind2ch_search($query); // �lj�
}
}

Expand Down
15 changes: 15 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -x
DIR=$(cd $(dirname $0); pwd)
cd $DIR

curl -O http://getcomposer.org/composer.phar || exit 1
chmod +x composer.phar || exit 1
mv composer.phar /usr/local/bin/composer || exit 1

/usr/local/bin/composer install || exit 1

chmod 0777 data/* rep2/ic || exit 1

php scripts/p2cmd.php check


7 changes: 7 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -x
DIR=$(cd $(dirname $0); pwd)
cd $DIR

php scripts/p2cmd.php update || exit 1