Random number in Thread Subject
Jumper Offline
Member
***
Posts: 75
Joined: Aug 2010
Post: #1
Random number in Thread Subject
Hi,

we have a plugin called "Report Thread". here the original File:

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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
/**
Report to Thread 0.1.3
----------------------

This program is free software: you can redistribute it and/or modify it under the terms of the 
GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. 
If not, see <http://www.gnu.org/licenses/>.
**/

if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook('report_do_report_end', 'reportthread_dopost');

function reportthread_info()
{
	return array(
		"name" => "Report To Thread",
		"description" => "Opens a discussion thread about the reported item when a user reports a post.",
		"website" => "http://forumgods.com/",
		"author" => "Tony Hudgins",
		"authorsite" => "http://forumgods.com/forums/member.php?160-Syke",
		"version" => "0.1.3",
		"compatibility" => "16*",
		"guid" => "8624478eb178c6eb37a503e960c267ec"
	);
}

function reportthread_install()
{
	global $db;
	
	$reported_group = array('gid' => 'NULL',
							'name' => 'reportthread',
							'title' => 'Report to Thread',
							'description' => 'Configure the Report to Thread plugin.',
							'disporder' => '1');
							
	$db->insert_query("settinggroups", $reported_group);
	$gid = $db->insert_id();
	
	$reported_setting1 = array('sid' => 'NULL',
							   'name' => 'rtt_enabled',
							   'title' => 'Enabled',
							   'description' => 'Whether or not to create new discussion threads for reported items.',
							   'optionscode' => 'yesno',
							   'value' => 'yes',
							   'disporder' => '1',
							   'gid' => intval($gid));
								   
	$reported_setting2 = array('sid' => 'NULL',
							   'name' => 'rtt_fid',
							   'title' => 'Forum ID',
							   'description' => 'The forum to post report threads to.',
							   'optionscode' => 'text',
							   'value' => '1',
							   'disporder' => '2',
							   'gid' => intval($gid));
								   
	$db->insert_query('settings', $reported_setting1);
	$db->insert_query('settings', $reported_setting2);
	
	rebuild_settings();
}

function reportthread_is_installed()
{
	global $db;
	
	$group = $db->query("SELECT `name` FROM `" . TABLE_PREFIX . "settinggroups` WHERE `name` = 'reportthread' LIMIT 1;");
	$s1 = $db->query("SELECT `name` FROM `" . TABLE_PREFIX . "settings` WHERE `name` = 'rtt_enabled' LIMIT 1;");
	$s2 = $db->query("SELECT `name` FROM `" . TABLE_PREFIX . "settings` WHERE `name` = 'rtt_fid' LIMIT 1;");
	
	if( $db->num_rows($group) >= 1 && $db->num_rows($s1) >= 1 && $db->num_rows($s2) )
		return true;
	else
		return false;
}

function reportthread_uninstall()
{
	global $db;
	
	$db->query("DELETE FROM `" . TABLE_PREFIX . "settinggroups` WHERE `name` = 'reportthread' LIMIT 1;");
	$db->query("DELETE FROM `" . TABLE_PREFIX . "settings` WHERE `name` = 'rtt_enabled' LIMIT 1;");
	$db->query("DELETE FROM `" . TABLE_PREFIX . "settings` WHERE `name` = 'rtt_fid' LIMIT 1;");
	
	rebuild_settings();
}

function reportthread_activate()
{
	global $db;
	
	$db->query("UPDATE `" . TABLE_PREFIX . "settings` SET `value` = 'yes' WHERE `name` = 'rtt_enabled' LIMIT 1;");
}

function reportthread_deactivate()
{
	global $db;
	
	$db->query("UPDATE `" . TABLE_PREFIX . "settings` SET `value` = 'no' WHERE `name` = 'rtt_enabled' LIMIT 1;");
}

function reportthread_dopost()
{
	require_once(MYBB_ROOT . "inc/datahandlers/post.php");
	global $db, $mybb;
	
	if(intval($mybb->settings['rtt_enabled']) == 1 || preg_replace("/[^a-z]/i", "", $mybb->settings['rtt_enabled']) == "yes")
	{
		$post = get_post($mybb->input['pid']);
		$thread = get_thread($post['tid']);
		$forum = get_forum($thread['fid']);
		
		$tlink = get_post_link($mybb->input['pid'],$post['tid'])."#pid".$mybb->input['pid'];
		$flink = get_forum_link($thread['fid']);
		
		$post_data = $mybb->user['username'] . " hat einen Beitrag gemeldet!

Original Thread: [url=" . $mybb->settings['bburl'] . "/$tlink]" . $thread['subject'] . "[/url]
Forum: [url=" . $mybb->settings['bburl'] . "/$flink]" . $forum['name'] . "[/url]
Uploader: [url={$mybb->settings['bburl']}/member.php?action=profile&uid=".($post['uid'])."]{$post['username']}[/url]

Angegebener Grund:
[quote=\"" . $mybb->user['username'] . "\" dateline=\"" . time() . "\"]" . $mybb->input['reason'] . "[/quote]

Beitrags Inhalt:
[quote=\"" . $post['username'] . "\" pid=\"" . $post['pid'] . "\" dateline=\"" . $post['dateline'] . "\"]" . $post['message'] . "[/quote]";
		
		$new_thread = array(
			"fid" => $mybb->settings['rtt_fid'],
			"prefix" => 0,
			"subject" => "[Meldung] Downfile: @" . $post['username'],
			"icon" => 0,
			"uid" => $mybb->user['uid'],
			"username" => $mybb->user['username'],
			"message" => $post_data,
			"ipaddress" => get_ip(),
			"posthash" => md5($mybb->user['uid'] . random_str()),
		);

		$posthandler = new PostDataHandler("insert");
		$posthandler->action = "thread";
		$posthandler->set_data($new_thread);
		
		if($posthandler->validate_thread())
			$thread_info = $posthandler->insert_thread();
	}
}
?>


now my problem:

we have a function, that a user cannot post the same subject 2 times. so we must have a solution, cause the downfile-reports have all the same subject. this line (144) is for the thread-subject:

PHP Code:
"subject" => "[Meldung] Downfile: @" . $post['username'],

Result: [Meldung] Downfile: @Username

and this is what i need: a random number behind "Meldung". so that it looks like this:

[Meldung257813] Downfile: @Username
257813 = the random number
the number must not be at this place. can look like this:
[Meldung] 257813 Downfile: @Username

But i must have a random number in thread subject. is this possible? would be great Wink

08-05-2012 04:01 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Random number in Thread Subject - Jumper - 08-05-2012 04:01 AM

 Standard Tools
Forum Jump: