2016-04-25, 10:09 PM
Hey guys, what's the problem with this code?
It didn't work but I don't know the error.
$help = array();
$query = $db->simple_select("bot_help", "*");
if($db->num_rows($query) > 0)
while($h = $db->fetch_array($query))
$help[$h['fid']] = $h['expire'];
$forum = array();
foreach($help as $v => $k)
$forum[] = $v;
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("insert");
$old = TIME_NOW - (60 * 60 * 24 * 10);
$ids = join(',', $forum);
$threads = $db->simple_select("threads", "tid, fid, username, subject", "lastpost <= {$old} AND closed != '1' AND visible = 1 AND fid IN ($ids)");
if($db->num_rows($threads) > 0) {
while($t = $db->fetch_array($threads)) {
if(array_key_exists($t['tid'], $help))
continue;
$post = array(
"tid" => $t['tid'],
"replyto" => $mybb->get_input('replyto', MyBB::INPUT_INT),
"fid" => $t['fid'],
"subject" => "RE: " . $t['subject'],
"icon" => $mybb->get_input('icon', MyBB::INPUT_INT),
"uid" => $mybb->user['uid'],
"username" => $mybb->user['username'],
"message" => "@{$['username']} il problema è stato risolto?",
"ipaddress" => $session->packedip,
"posthash" => md5($t['tid'].$mybb->user['uid'].random_str())
);
$post['options'] = array(
"signature" => 1,
"subscriptionmethod" => 0,
"disablesmilies" => 0
);
$posthandler->set_data($post);
$valid_post = $posthandler->validate_post();
$postinfo = $posthandler->insert_post();
$pid = $postinfo['pid'];
$visible = $postinfo['visible'];
$closed = $postinfo['closed'];
$data = array(
"fid" => $t['tid'],
"time" => TIME_NOW,
"expire" => TIME_NOW + (60 * 60 * 24 * 10);
);
$db->insert_query("bot_help", $data);
}
}
It didn't work but I don't know the error.