Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Adding threads with xThreads fields (file0 with PHP
Victor Offline
Junior Member
**
Posts: 6
Joined: Aug 2012
Post: #1
Adding threads with xThreads fields (file0 with PHP
Hello.

My little PHP code is:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
define('IN_MYBB', true);
define('THIS_SCRIPT', "newthread.php");

global $current_page, $fid, $forum, $plugins, $cache, $_FILES, $mybb;
$fid = 50;
$current_page = "newthread.php";
$mybb->request_method = "post";

include 'global.php';
require_once MYBB_ROOT."inc/functions.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
require_once MYBB_ROOT."inc/functions_indicators.php";
require_once MYBB_ROOT."inc/datahandlers/post.php";

$forum = get_forum($fid);

xthreads_gettfcache($fid);
foreach (glob("new_photos/*.txt") as $filename)
{
	$data = unserialize(file_get_contents($filename));

	$_FILES['xthreads_gal_img']['name'] = $data['id'] .".".$data['ext'];
	$_FILES['xthreads_gal_img']['size'] = filesize(MYBB_ROOT."new_photos/" . $data['id'] .".".$data['ext']);
	$_FILES['xthreads_gal_img']['tmp_name'] = MYBB_ROOT."new_photos/" . $data['id'] .".".$data['ext'];

	// Set the thread data that came from the input to the $thread array.
	$new_thread = array(
		"fid" => $fid,
		"xthreads_gal_cat" => $data['category'],
		"xtasel_gal_img" => "file",
		"action" => "do_newthread",
		"xthreads_gal_img" => 1,
		"subject" => $data['title'],
		"icon" => -1,
		"uid" => 878,
		"username" => "Importer fotek",
		"message" => $data['desc'],
		"ipaddress" => get_ip(),
		"posthash" => md5("878".random_str()),
		'savedraft' => 0
	);
	
	$mybb->input = &$new_thread;
	
	$plugins->run_hooks("newthread_do_newthread_start");
	
	$posthandler = new PostDataHandler("insert");
	$posthandler->action = "thread";
	$posthandler->set_data($new_thread);
	
	if($posthandler->validate_thread()) { $posthandler->insert_thread(); } else {var_dump($posthandler->get_errors());}

	$plugins->run_hooks("newthread_do_newthread_end");
}
?>


In txt file in new_photos/ i've got for instance:

Quote:a:6:{s:2:"id";i:1;s:5:"title";s:20:"I się zaczęło :-)";s:4:"date";s:10:"1257760336";s:8:"category";s:38:"2002r - I ogólnopolski zlot - Bemowo ";s:4:"desc";s:438:"I ogólnopolski zlot smartów odbył się 1 maja 2002r. na Lotnisku-Bemowo w Warszawie, przy okazji Zlotu Aut Tuningowych. Było to pierwsze spotkanie klubowe. Po raz pierwszy mieliśmy okazję do spotkania się w trochę większym gronie i zaprezentowania swoich aut. Dwa smarty wzięły również udział w wyścigu na 1/4 mili. Ostatecznie jeden z nich zajął 24 miejsce, co jest bardzo dobrym wynikiem, jak na autko klasy super-mini.";s:3:"ext";s:3:"jpg";}

Everything works great until... it doesn't move upload xthread field file as I want.
[Image: OxzSu.jpg]

I hope developer can help me. It's really hard to understand back-end of xThreads for such programmer as I am.

Looking forward Smile
(This post was last modified: 11-11-2012 10:46 PM by Victor.)
11-11-2012 10:34 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Adding threads with xThreads fields (file0 with PHP - Victor - 11-11-2012 10:34 PM

 Standard Tools
Forum Jump: