Compatable With Simple Portal's "Recent Topics"
Usage:
php bump_topic.php nnnnn
<?php
// Usage:
// php bump_topic.php <topic_id>
if (php_sapi_name() != 'cli')
die("CLI only\n");
require_once(dirname(__FILE__) . '/SSI.php');
if ($argc != 2)
die("Usage: php bump_topic.php <topic_id>\n");
$topic_id = (int)$argv[1];
$now = time();
$member = 1; // change to your admin member ID
// Get topic info
$request = $smcFunc['db_query']('', '
SELECT id_board, id_first_msg
FROM {db_prefix}topics
WHERE id_topic = {int:id_topic}',
array('id_topic' => $topic_id)
);
if (!$row = $smcFunc['db_fetch_assoc']($request))
die("Topic not found\n");
$id_board = $row['id_board'];
// Insert a reply
$smcFunc['db_insert']('',
'{db_prefix}messages',
array(
'id_board' => 'int',
'id_topic' => 'int',
'id_member' => 'int',
'poster_time' => 'int',
'poster_name' => 'string',
'body' => 'string',
'poster_ip' => 'string',
),
array(
$id_board,
$topic_id,
$member,
$now,
'Admin',
'Topic bumped',
'127.0.0.1',
),
array('id_msg')
);
$new_msg = $smcFunc['db_insert_id']('{db_prefix}messages', 'id_msg');
// Update topic
$smcFunc['db_query']('', '
UPDATE {db_prefix}topics
SET id_last_msg = {int:id_msg}
WHERE id_topic = {int:id_topic}',
array(
'id_msg' => $new_msg,
'id_topic' => $topic_id
)
);
// Update board
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET id_last_msg = {int:id_msg}
WHERE id_board = {int:id_board}',
array(
'id_msg' => $new_msg,
'id_board' => $id_board
)
);
echo "Topic bumped with new message ID {$new_msg}\n";