Solved: 4 Years, 10 Months, 1 Week ago code problem
#1
Solved: 4 Years, 10 Months, 1 Week ago
Hey guys, what's the problem with this code?
$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.
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#2
Solved: 4 Years, 10 Months, 1 Week ago
Anyone can help me?
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#3
Solved: 4 Years, 10 Months, 1 Week ago
Can you tell us how it didn't work? What were you expecting to happen, what happened instead?
Reply
#4
Solved: 4 Years, 10 Months, 1 Week ago
It didn't post new post and didn't insert fields in table. I can't see the error because only my bot can execute the code
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#5
Solved: 4 Years, 10 Months, 1 Week ago
Up Sad
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#6
Solved: 4 Years, 10 Months, 1 Week ago
It shows me this errore:

Fatal error: Call to a member function getByCode() on boolean in /customers/1/7/0/mybb-it.com/httpd.www/inc/plugins/myalerts.php on line 891

I can't uninstall MyAlerts, how to fix this problem?

@Euan T
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#7
Solved: 4 Years, 10 Months, 1 Week ago
Hi, are you acting as a guest user when this happens? If so, it's a known bug in myAlerts which I will be trying to fix tomorrow.
Reply
#8
Solved: 4 Years, 10 Months, 1 Week ago
No, my bot is logged when it try to insert a post
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#9
Solved: 4 Years, 10 Months, 1 Week ago
Interesting. It still sounds semi-related, so the patch I'll be making tomorrow should solve that.
Reply
#10
Solved: 4 Years, 10 Months, 1 Week ago
The problem is with this code:
$postinfo = $posthandler->insert_post();

@Euan T I think it isn't a problem of myAlerts. These are data of variable $post sent to MyAlerts function:
PostDataHandler Object
(
    [language_file] => datahandler_post
    [language_prefix] => postdata
    [action] => post
    [post_insert_data] => Array
        (
            [tid] => 254
            [replyto] => 1956
            [fid] => 11
            [subject] => RE: AIUTO Costruzione forum
            [icon] => 0
            [uid] => 286
            [username] => Bot Mark
            [dateline] => 1462132642
            [message] => @ITFA il problema è stato risolto?
            [ipaddress] => X'5ffcbe82'
            [includesig] => 0
            [smilieoff] => 0
            [visible] => 1
        )

    [post_update_data] => Array
        (
        )

    [pid] => 0
    [thread_insert_data] => Array
        (
        )

    [thread_update_data] => Array
        (
        )

    [tid] => 0
    [return_values] => Array
        (
        )

    [first_post] => 
    [data] => Array
        (
            [tid] => 254
            [replyto] => 1956
            [fid] => 11
            [subject] => RE: AIUTO Costruzione forum
            [icon] => 0
            [uid] => 286
            [username] => Bot Mark
            [message] => @ITFA il problema è stato risolto?
            [ipaddress] => _ü¾‚
            [posthash] => 56492be63f5d089fa656216faffcf5a3
            [savedraft] => 0
            [options] => Array
                (
                    [signature] => 0
                    [subscriptionmethod] => 0
                    [disablesmilies] => 0
                )

            [dateline] => 1462132642
            [pid] => 0
        )

    [is_validated] => 1
    [errors] => Array
        (
        )

    [admin_override] => 
    [method] => insert
)

Watch pid and tid...
My Projects - Support My Projects

Don't forget to rate posts!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)