MyBB Community Forums

Full Version: How can i fix this ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
https://mods.mybb.com/view/new-thread

here is this plugin , i just installed it in in recent version of mybb. and shows too much error in www.website.com/new.php

here i have attached a screenshot of that [attachment=43698]

can anyone please tell me how can i fix this ? how can run it in recent version of mybb ? I have also installed Xthread in my site. Can be this a cause for this bug ?

My site :- https://gossipion.xyz
Username:- Test
Password:- test1234
I think you should talk with your host to upgrade php version
(2021-01-28, 11:54 AM)Mastersly Wrote: [ -> ]I think you should talk with your host to upgrade php version
[Image: IMG-20210128-173250.jpg]

[Image: IMG-20210128-173233.jpg]

see this.... i have already upgraded....

it shows error in line inc/plugins/new.php line 172

and root/new.php line 26

line 172 :-
				$forum .= "<option value=\"".$forums[fid]."\">".$forums[name]."</option>"; 
			}
line 26:-
$forumsselected = cache_forums_select();
What is the plugin that uses the new.php file?
(2021-01-28, 03:38 PM)Ben Wrote: [ -> ]What is the plugin that uses the new.php file?

https://mods.mybb.com/view/new-thread
This is the plugin...
You shouldn't use old plugins that are not fully compatible with 1.8, that was is for 1.6..
(2021-01-28, 12:04 PM)PARADOXP Wrote: [ -> ]
$forum .= "<option value=\"".$forums[fid]."\">".$forums[name]."</option>"; 
 }

The code doesn't respect basis:
$forum .= "<option value=\"".$forums['fid']."\">".$forums['name']."</option>"; 
 }

You'll have to check the whole plugin to ensure all array indexes are well protected
(2021-01-29, 02:26 PM)Crazycat Wrote: [ -> ]
(2021-01-28, 12:04 PM)PARADOXP Wrote: [ -> ]
$forum .= "<option value=\"".$forums[fid]."\">".$forums[name]."</option>"; 
 }

The code doesn't respect basis:
$forum .= "<option value=\"".$forums['fid']."\">".$forums['name']."</option>"; 
 }

You'll have to check the whole plugin to ensure all array indexes are well protected

You are a lifesaver....
Adore You 💗😊...
Now it works well....


And one more thing...
(2021-01-20, 02:41 PM)Crazycat Wrote: [ -> ]I think it's possible to have a plugin doing that.
It's already possible to filter showthread by prefix (example: https://community.mybb.com/forum-176.html?prefix=8), so the job is just to add the selection of the prefix.

I'll try to work on that soon

what about it ? 😄
(2021-01-29, 07:53 PM)PARADOXP Wrote: [ -> ]Now it works well....

not exactly....., as if you actually look at the plugin there are some issues due to 1.8 ie(thread subs, post options, mod options, etc, etc, and while I do not have time to fully look at this perhaps this as a starting point will get you further towards your aims...

as you will note in existing plug on 1.8

these (post options, sig, mod options, some subs, etc) are not all functioning correctly and or are not all displaying:

[Image: New-Thread-in-1.png]
* note: screen is from noticing those items were not all correctly working and making minor changes made to emphasize hey now look it is now working as far as that section... lol... jest saying Wink


<?php
/**
 * MyBB
 * New Thread
 * Create a thread in the forum that you want
 * Website: http://www.mybb-es.com
 *
 * Edson Ordaz
 */

if(!defined("IN_MYBB"))
{

	die("This file cannot be accessed directly.");

}

$plugins->add_hook("new_thread_start","new_thread_function");

function new_info()
{
	return array(
		"name"			=> "New Thread",
		"description"	=> "Create a thread in the forum that you want",
		"website"		=> "http://www.mybb-es.com",
		"author"		=> "Edson Ordaz & minor edits by Vintagedaddyo",
		"authorsite"	=> "mailto:[email protected]",
		"version"		=> "1.1",
		"compatibility" => "18*",
		"guid"			=> "d38c8b8f8919cfccdb9596354fe510b5"
	);
}


function new_activate(){

	global $db;

// {$lang->nav_newthread} <!-- {$lang->newthread_in} --> ? //

  	$new_thread  = array(
		"tid" => "0",
		"title" => "new_thread",
		"template" => $db->escape_string('<html>
<head>
<title>{$lang->nav_newthread}</title>
{$headerinclude}
<script type="text/javascript" src="jscripts/post.js?ver=1800"></script>
</head>
<body>
{$header}
{$preview}
{$thread_errors}
{$attacherror}
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
<td class="thead"><strong>{$lang->post_new_thread}</strong></td>
</tr>
<tr>
<td class="trow2" width="100%">
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" width="100%">
<td align="left" width="60%">
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" width="100%">
<tr>
<form action="newthread.php" method="post" enctype="multipart/form-data" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<td class="trow2">
<span style="font-size:18px;font-weight: bold;">{$lang->thread_subject}</span><br />
<input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
</tr>
<td class="trow2">
<span style="font-size:18px;font-weight: bold;">{$lang->your_message}</span><br />
<textarea name="message" id="message" rows="20" cols="70" tabindex="2">{$message}</textarea>
{$codebuttons}
</td>
</tr>
</table>
</td>
<td align="right" valign="top" width="40%">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span style="font-size:18px;font-weight: bold;">{$lang->forumbit_forum}:</span><br />
{$forumsselected}
</td>
</tr>
</table>
</td>
</table>
</td>
</tr>
<tr>
<td class="trow1" valign="top"><strong>{$lang->post_options}</strong><br/><span class="smalltext">
<label><input type="checkbox" class="checkbox" name="postoptions[signature]" value="1" tabindex="7"{$postoptionschecked[\'signature\']} />{$lang->options_sig}</label>
</span></td>
</tr>
{$modoptions}
{$subscriptionmethod}
{$pollbox}
</table>
<br />
<div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->post_thread}" tabindex="4" accesskey="s" />  <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="5" />{$savedraftbutton}</div>
<input type="hidden" name="action" value="do_newthread" />
<input type="hidden" name="posthash" value="{$posthash}" />
<input type="hidden" name="attachmentaid" value="" />
<input type="hidden" name="attachmentact" value="" />
<input type="hidden" name="quoted_ids" value="{$quoted_ids}" />
<input type="hidden" name="tid" value="{$tid}" />
{$editdraftpid}
</form>
{$forumrules}
{$footer}
</body>
</html>'),
		"sid" => "-1",
	);

	$new_thread_modoptions  = array(
		"tid" => "0",
		"title" => "new_thread_modoptions",
		"template" => $db->escape_string('<tr>
<td class="trow2" valign="top"><strong>{$lang->mod_options}</strong>
<br class="clear" />
<label><input type="checkbox" class="checkbox" name="modoptions[closethread]" value="1"{$closecheck} />&nbsp;{$lang->close_thread}</label><br />
<label><input type="checkbox" class="checkbox" name="modoptions[stickthread]" value="1"{$stickycheck} />&nbsp;{$lang->stick_thread}</label>
</span></td>
</tr>'),
		"sid" => "-1",
	);

	$new_thread_postpoll  = array(
		"tid" => "0",
		"title" => "new_thread_postpoll",
		"template" => $db->escape_string('<tr>
<td class="{$bgcolor2}" valign="top">
<strong>{$lang->poll}</strong><br /><span class="smalltext">{$lang->poll_desc}</span>
<br class="clear" />
<span class="smalltext"><label><input type="checkbox" class="checkbox" name="postpoll" value="1" {$postpollchecked} /><strong>{$lang->poll_check}</strong></label><br />
{$lang->num_options} <input type="text" class="textbox" name="numpolloptions" value="{$numpolloptions}" size="10" /> {$lang->max_options}</span>
</td>
</tr>'),
		"sid" => "-1",
	);

	$new_thread_subscription  = array(
		"tid" => "0",
		"title" => "new_thread_subscription",
		"template" => $db->escape_string('<tr>
<td class="{$bgcolor}" valign="top"><strong>{$lang->thread_subscription_method}</strong><br />
<span class="smalltext">{$lang->thread_subscription_method_desc}</span>
<br class="clear" />
	<label><input type="radio" name="postoptions[subscriptionmethod]" {$subscribe}value="" style="vertical-align: middle;" /> {$lang->no_subscribe}</label><br />
	<label><input type="radio" name="postoptions[subscriptionmethod]" {$nonesubscribe}value="none" style="vertical-align: middle;" /> {$lang->no_subscribe_notification}</label><br />
	<label><input type="radio" name="postoptions[subscriptionmethod]" {$emailsubscribe}value="email" style="vertical-align: middle;" /> {$lang->instant_email_subscribe}</label><br />
	<label><input type="radio" name="postoptions[subscriptionmethod]" {$pmsubscribe}value="pm" style="vertical-align: middle;" /> {$lang->instant_pm_subscribe}</label><br />
</td>
</tr>'),
		"sid" => "-1",
	);

	$db->insert_query("templates", $new_thread);

	$db->insert_query("templates", $new_thread_modoptions);

	$db->insert_query("templates", $new_thread_postpoll);

	$db->insert_query("templates", $new_thread_subscription);
}

function new_deactivate(){

	global $db;

	$db->delete_query("templates","title = 'new_thread'");

	$db->delete_query("templates","title = 'new_thread_modoptions'");

	$db->delete_query("templates","title = 'new_thread_postpoll'");

	$db->delete_query("templates","title = 'new_thread_subscription'");
}

function new_thread_function()
{
	function cache_forums_select($size=24,$width=230)
	{
		global $forum_cache, $cache;
		
		if(!$forum_cache)
		{
			$forum_cache = $cache->read("forums");

			if(!$forum_cache)
			{
				$cache->update_forums();

				$forum_cache = $cache->read("forums", 1);

			}
		}

		$forum = array();

	    foreach($forum_cache as $forums)
	    {
			
			if($forums['type'] != "c")
			{

				$forum .= "<option value=\"".$forums['fid']."\">".$forums['name']."</option>"; 

			}
	    }
	    $forum_selected = "<select name=\"fid\" size=\"{$size}\" style=\"width: {$width}px\">
		".$forum."</select>";

		return $forum_selected;

	}
}

?>

* in theory though even after minor template changes above in the plugin, one thought is that for someone that has the free time to do so perhaps the plugins global new_thread template should still possibly be considered to be edited further at some point to reflect any further noticeable changes from 1.6 to the 1.8.x newthread template

something else to note:

you might want to change:

in "forums_root_dir"/new.php

eval("\$modoptions = \"".$templates->get("new_thread_modoptions")."\";");

eval("\$subscriptionmethod = \"".$templates->get("new_thread_subscription")."\";");

eval("\$pollbox = \"".$templates->get("new_thread_postpoll")."\";");

eval("\$savedraftbutton = \"".$templates->get("post_savedraftbutton", 1, 0)."\";");

$forumsselected = cache_forums_select();

eval("\$page_new_thread = \"".$templates->get("new_thread", 1, 0)."\";");

output_page($page_new_thread);

to something like:

global $db, $user;

if($mybb->usergroup['canmodcp']) {

eval("\$modoptions = \"".$templates->get("new_thread_modoptions")."\";");

}

if($mybb->user['uid']) {

eval("\$subscriptionmethod = \"".$templates->get("new_thread_subscription")."\";");

eval("\$pollbox = \"".$templates->get("new_thread_postpoll")."\";");

eval("\$savedraftbutton = \"".$templates->get("post_savedraftbutton", 1, 0)."\";");

$forumsselected = cache_forums_select();

eval("\$page_new_thread = \"".$templates->get("new_thread", 1, 0)."\";");

output_page($page_new_thread);

}

if($mybb->user['uid'] == 0) {
    error_no_permission();
}

* primarily because you will note that new.php file is displayed to non registered users, so the edit above stops the new.php from being displayed to non registered non logged in users. oh, and also the modoptions should only be displayed to users than "canmodcp" so the edit above does that.... all while displaying a no permissions page to non registered users....


one other thing is while factoring those previous changes, we also need to add threadprefix, and loginbox and posticons so after all suggested previous edits and lastly adding thread prefix selector loginbox and posticons, your end result should be similar to:

ie:
[Image: Post-a-new-Thread-3.png]


forum(root)/inc/plugins/new.php

<?php
/**
 * MyBB
 * New Thread
 * Create a thread in the forum that you want
 * Website: http://www.mybb-es.com
 *
 * Author(s): Edson Ordaz & Vintagedaddyo
 * 
 * File: inc/plugins/new.php
 *
 * Version: 1.1
 *
 */

if(!defined("IN_MYBB"))
{

	die("This file cannot be accessed directly.");

}

$plugins->add_hook("new_thread_start","new_thread_function");

function new_info()
{
	return array(
		"name"			=> "New Thread",
		"description"	=> "Create a thread in the forum that you want",
		"website"		=> "http://www.mybb-es.com",
		"author"		=> "Edson Ordaz & minor edits by Vintagedaddyo",
		"authorsite"	=> "mailto:[email protected]",
		"version"		=> "1.1",
		"compatibility" => "18*",
		"guid"			=> "d38c8b8f8919cfccdb9596354fe510b5"
	);
}


function new_activate(){

	global $db;

  	$new_thread  = array(
		"tid" => "0",
		"title" => "new_thread",
		"template" => $db->escape_string('<html>
   <head>
      <title>{$lang->post_new_thread}</title>
      {$headerinclude}
      {$post_javascript}
   </head>
   <body>
      {$header}
      {$preview}
      {$thread_errors}
      {$attacherror}
      <form action="newthread.php" method="post" enctype="multipart/form-data" name="input">
         <input type="hidden" name="my_post_key" value="{$mybb->post_code}" />   
         <table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
            <tr>
               <td class="thead"><strong>{$lang->post_new_thread}</strong></td>
            </tr>
            <tr>
               <td class="trow2" width="100%">
                  <table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" width="100%">
                     <td align="left" width="80%">
                        <table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" width="100%">
                           <tr>
                              <td valign="top">
                                 <table border="0" cellspacing="0" cellpadding="5" class="tborder" style="background: #ddd;">
                                    <td>
                                       {$loginbox}    
                                    </td>
                                 </table>
                              </td>
                           <tr>                             
                              <td class="trow2">   
                                 <span style="font-size:18px;"><strong>{$lang->thread_subject}</strong></span><br />
                                 {$prefixselect} <input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" />
                                 <br />
                              </td>
                           </tr>
                           <tr>
                              <td valign="top">
                                 <table border="0" cellspacing="0" cellpadding="5" class="tborder" style="background: #ddd;">
                                    <td>
                                       {$posticons}      
                                    </td>
                                 </table>
                              </td>
                          </tr>
                           <tr> 
                              <td class="trow2">                             
                                 <br />
                                 <span style="font-size:18px;"><strong>{$lang->your_message}</strong></span><br />
                                 <textarea name="message" id="message" rows="20" cols="70" tabindex="2">{$message}</textarea>
                                 {$codebuttons}
                              </td>
                           </tr>
                           </tr>
                        </table>
                     </td>
                     <td align="right" valign="top" width="20%">
                        <table border="0" cellspacing="0" cellpadding="0">
                           <tr>
                              <td><span style="font-size:18px;"><strong>{$lang->forumbit_forum}:</strong></span><br />
                                 {$forumsselected}
                              </td>
                           </tr>
                        </table>
                     </td>
                  </table>
               </td>
            </tr>
            {$postoptions}
            {$modoptions}
            {$subscriptionmethod}
            {$pollbox}
         </table>
         <br />
         <div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->post_thread}" tabindex="4" accesskey="s" />  <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="5" />{$savedraftbutton}</div>
         <input type="hidden" name="action" value="do_newthread" />
         <input type="hidden" name="posthash" value="{$posthash}" />
         <input type="hidden" name="attachmentaid" value="" />
         <input type="hidden" name="attachmentact" value="" />
         <input type="hidden" name="quoted_ids" value="{$quoted_ids}" />
         <input type="hidden" name="tid" value="{$tid}" />
         {$editdraftpid}
      </form>
      {$forumrules}
      {$footer}
   </body>
</html>'),
		"sid" => "-1",
	);

	$new_thread_postoptions  = array(
		"tid" => "0",
		"title" => "new_thread_postoptions",
		"template" => $db->escape_string('<tr>
   <td class="trow2" valign="top"><strong>{$lang->post_options}</strong>
      <br class="clear" />
      <label><input type="checkbox" class="checkbox" name="postoptions[signature]" value="1" tabindex="7"{$postoptionschecked[\'signature\']} /> {$lang->options_sig}</label><br />
      <label><input type="checkbox" class="checkbox" name="postoptions[disablesmilies]" value="1" tabindex="9"{$postoptionschecked[\'disablesmilies\']} /> {$lang->options_disablesmilies}</label>
      </span>
   </td>
</tr>'),
		"sid" => "-1",
	);	

	$new_thread_modoptions  = array(
		"tid" => "0",
		"title" => "new_thread_modoptions",
		"template" => $db->escape_string('<tr>
   <td class="trow2" valign="top"><strong>{$lang->mod_options}</strong>
      <br class="clear" />
      <label><input type="checkbox" class="checkbox" name="modoptions[closethread]" value="1"{$closecheck} />&nbsp;{$lang->close_thread}</label><br />
      <label><input type="checkbox" class="checkbox" name="modoptions[stickthread]" value="1"{$stickycheck} />&nbsp;{$lang->stick_thread}</label>
      </span>
   </td>
</tr>'),
		"sid" => "-1",
	);

	$new_thread_postpoll  = array(
		"tid" => "0",
		"title" => "new_thread_postpoll",
		"template" => $db->escape_string('<tr>
   <td class="{$bgcolor}" valign="top">
      <strong>{$lang->poll}</strong><br /><span class="smalltext">{$lang->poll_desc}</span>
      <br class="clear" />
      <span class="smalltext"><label><input type="checkbox" class="checkbox" name="postpoll" value="1" {$postpollchecked} /><strong>{$lang->poll_check}</strong></label><br />
      {$lang->num_options} <input type="text" class="textbox" name="numpolloptions" value="{$numpolloptions}" size="10" /> {$lang->max_options}</span>
   </td>
</tr>'),
		"sid" => "-1",
	);

	$new_thread_subscriptionmethod  = array(
		"tid" => "0",
		"title" => "new_thread_subscriptionmethod",
		"template" => $db->escape_string('<tr>
   <td class="{$bgcolor}" valign="top"><strong>{$lang->thread_subscription_method}</strong><br />
      <span class="smalltext">{$lang->thread_subscription_method_desc}</span>
      <br class="clear" />
      <label><input type="radio" name="postoptions[subscriptionmethod]" {$subscribe}value="" style="vertical-align: middle;" /> {$lang->no_subscribe}</label><br />
      <label><input type="radio" name="postoptions[subscriptionmethod]" {$nonesubscribe}value="none" style="vertical-align: middle;" /> {$lang->no_subscribe_notification}</label><br />
      <label><input type="radio" name="postoptions[subscriptionmethod]" {$emailsubscribe}value="email" style="vertical-align: middle;" /> {$lang->instant_email_subscribe}</label><br />
      <label><input type="radio" name="postoptions[subscriptionmethod]" {$pmsubscribe}value="pm" style="vertical-align: middle;" /> {$lang->instant_pm_subscribe}</label><br />
   </td>
</tr>'),
		"sid" => "-1",
	);

	$db->insert_query("templates", $new_thread);

	$db->insert_query("templates", $new_thread_modoptions);

	$db->insert_query("templates", $new_thread_postoptions);	

	$db->insert_query("templates", $new_thread_postpoll);

	$db->insert_query("templates", $new_thread_subscriptionmethod);
}

function new_deactivate(){

	global $db;

	$db->delete_query("templates","title = 'new_thread'");

	$db->delete_query("templates","title = 'new_thread_postoptions'");	

	$db->delete_query("templates","title = 'new_thread_modoptions'");

	$db->delete_query("templates","title = 'new_thread_postpoll'");

	$db->delete_query("templates","title = 'new_thread_subscriptionmethod'");
}

function new_thread_function()
{
	function cache_forums_select($size=24,$width=230)
	{
		global $forum_cache, $cache;
		
		if(!$forum_cache)
		{
			$forum_cache = $cache->read("forums");

			if(!$forum_cache)
			{
				$cache->update_forums();

				$forum_cache = $cache->read("forums", 1);

			}
		}

		$forum = array();

	    foreach($forum_cache as $forums)
	    {
			
			if($forums['type'] != "c")
			{

				$forum .= "<option value=\"".$forums['fid']."\">".$forums['name']."</option>"; 

			}
	    }
	    $forum_selected = "<select name=\"fid\" size=\"{$size}\" style=\"width: {$width}px\">
		".$forum."</select>";

		return $forum_selected;

	}
}

?>

forum(root)/new.php

<?php
/**
 * MyBB
 * New Thread
 * Create a thread in the forum that you want
 * Website: http://www.mybb-es.com
 *
 * Author(s): Edson Ordaz & Vintagedaddyo
 * 
 * File: new.php
 *
 * Version: 1.1
 *
 */

define("IN_MYBB", 1);

define("KILL_GLOBALS", 1);

require_once "./global.php";

$lang->load("newthread", false, true);

$lang->max_options = $lang->sprintf($lang->max_options, $mybb->settings['maxpolloptions']);

add_breadcrumb("New Thread", "new.php");

$plugins->run_hooks('new_thread_start');

global $db, $mybb, $lang, $user;

$prefixselect = build_prefix_select($forum['fid'], $mybb->get_input('threadprefix', MyBB::INPUT_INT));

$icon = $post['icon'];

$posticons = get_post_icons();

// If we have a currently logged in user then fetch the change user box.

if($mybb->user['uid'] != 0)
{
	$mybb->user['username'] = htmlspecialchars_uni($mybb->user['username']);
	eval("\$loginbox = \"".$templates->get("changeuserbox")."\";");
}

// Otherwise we have a guest, determine the "username" and get the login box.

else
{
	if(!isset($mybb->input['previewpost']) && $mybb->input['action'] != "do_newthread")
	{
		$username = '';
	}
	else
	{
		$username = htmlspecialchars_uni($mybb->get_input('username'));
	}
	eval("\$loginbox = \"".$templates->get("loginbox")."\";");
}

$codebuttons = build_mycode_inserter();

$modoptions = $mybb->input['modoptions'];

if($modoptions['closethread'] == 1) {

	$closecheck = "checked=\"checked\"";

}

else {

	$closecheck = '';

}

if($modoptions['stickthread'] == 1) {

	$stickycheck = "checked=\"checked\"";

}

else {

	$stickycheck = '';

}

unset($modoptions);

$bgcolor = alt_trow();

if($mybb->usergroup['canmodcp']) {

eval("\$modoptions = \"".$templates->get("new_thread_modoptions")."\";");

}

if($mybb->user['uid']) {

eval("\$postoptions = \"".$templates->get("new_thread_postoptions")."\";");	

eval("\$subscriptionmethod = \"".$templates->get("new_thread_subscriptionmethod")."\";");

eval("\$pollbox = \"".$templates->get("new_thread_postpoll")."\";");

eval("\$savedraftbutton = \"".$templates->get("post_savedraftbutton", 1, 0)."\";");

require_once MYBB_ROOT."/inc/cachehandlers/interface.php";

$forumsselected = cache_forums_select();

eval("\$page_new_thread = \"".$templates->get("new_thread", 1, 0)."\";");

output_page($page_new_thread);

}

if($mybb->user['uid'] == 0) {

    error_no_permission();

}

?>
(2021-01-29, 09:31 PM)censor_deeznutz Wrote: [ -> ]
(2021-01-29, 07:53 PM)PARADOXP Wrote: [ -> ]Now it works well....

not exactly....., as if you actually look at the plugin there are some issues due to 1.8 ie(thread subs, post options, mod options, etc, etc, and while I do not have time to fully look at this perhaps this as a starting point will get you further towards your aims...

as you will note in existing plug on 1.8

these (post options, sig, mod options, some subs, etc) are not all functioning correctly and or are not all displaying:

[Image: New-Thread-in-1.png]
* note: screen is from noticing those items were not all correctly working and making minor changes made to emphasize hey now look it is now working as far as that section... lol... jest saying Wink


<?php
/**
 * MyBB
 * New Thread
 * Create a thread in the forum that you want
 * Website: http://www.mybb-es.com
 *
 * Edson Ordaz
 */

if(!defined("IN_MYBB"))
{

	die("This file cannot be accessed directly.");

}

$plugins->add_hook("new_thread_start","new_thread_function");

function new_info()
{
	return array(
		"name"			=> "New Thread",
		"description"	=> "Create a thread in the forum that you want",
		"website"		=> "http://www.mybb-es.com",
		"author"		=> "Edson Ordaz & minor edits by Vintagedaddyo",
		"authorsite"	=> "mailto:[email protected]",
		"version"		=> "1.1",
		"compatibility" => "18*",
		"guid"			=> "d38c8b8f8919cfccdb9596354fe510b5"
	);
}


function new_activate(){

	global $db;

// {$lang->nav_newthread} <!-- {$lang->newthread_in} --> ? //

  	$new_thread  = array(
		"tid" => "0",
		"title" => "new_thread",
		"template" => $db->escape_string('<html>
<head>
<title>{$lang->nav_newthread}</title>
{$headerinclude}
<script type="text/javascript" src="jscripts/post.js?ver=1800"></script>
</head>
<body>
{$header}
{$preview}
{$thread_errors}
{$attacherror}
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
<td class="thead"><strong>{$lang->post_new_thread}</strong></td>
</tr>
<tr>
<td class="trow2" width="100%">
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" width="100%">
<td align="left" width="60%">
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" width="100%">
<tr>
<form action="newthread.php" method="post" enctype="multipart/form-data" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<td class="trow2">
<span style="font-size:18px;font-weight: bold;">{$lang->thread_subject}</span><br />
<input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
</tr>
<td class="trow2">
<span style="font-size:18px;font-weight: bold;">{$lang->your_message}</span><br />
<textarea name="message" id="message" rows="20" cols="70" tabindex="2">{$message}</textarea>
{$codebuttons}
</td>
</tr>
</table>
</td>
<td align="rigth" valign="top" width="40%">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span style="font-size:18px;font-weight: bold;">{$lang->forumbit_forum}:</span><br />
{$forumsselected}
</td>
</tr>
</table>
</td>
</table>
</td>
</tr>
<tr>
<td class="trow1" valign="top"><strong>{$lang->post_options}</strong><br/><span class="smalltext">
<label><input type="checkbox" class="checkbox" name="postoptions[signature]" value="1" tabindex="7"{$postoptionschecked[\'signature\']} />{$lang->options_sig}</label>
</span></td>
</tr>
{$modoptions}
{$subscriptionmethod}
{$pollbox}
</table>
<br />
<div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->post_thread}" tabindex="4" accesskey="s" />  <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="5" />{$savedraftbutton}</div>
<input type="hidden" name="action" value="do_newthread" />
<input type="hidden" name="posthash" value="{$posthash}" />
<input type="hidden" name="attachmentaid" value="" />
<input type="hidden" name="attachmentact" value="" />
<input type="hidden" name="quoted_ids" value="{$quoted_ids}" />
<input type="hidden" name="tid" value="{$tid}" />
{$editdraftpid}
</form>
{$forumrules}
{$footer}
</body>
</html>'),
		"sid" => "-1",
	);

	$new_thread_modoptions  = array(
		"tid" => "0",
		"title" => "new_thread_modoptions",
		"template" => $db->escape_string('<tr>
<td class="trow2" valign="top"><strong>{$lang->mod_options}</strong>
<br class="clear" />
<label><input type="checkbox" class="checkbox" name="modoptions[closethread]" value="1"{$closecheck} />&nbsp;{$lang->close_thread}</label><br />
<label><input type="checkbox" class="checkbox" name="modoptions[stickthread]" value="1"{$stickycheck} />&nbsp;{$lang->stick_thread}</label>
</span></td>
</tr>'),
		"sid" => "-1",
	);

	$new_thread_postpoll  = array(
		"tid" => "0",
		"title" => "new_thread_postpoll",
		"template" => $db->escape_string('<tr>
<td class="{$bgcolor2}" valign="top">
<strong>{$lang->poll}</strong><br /><span class="smalltext">{$lang->poll_desc}</span>
<br class="clear" />
<span class="smalltext"><label><input type="checkbox" class="checkbox" name="postpoll" value="1" {$postpollchecked} /><strong>{$lang->poll_check}</strong></label><br />
{$lang->num_options} <input type="text" class="textbox" name="numpolloptions" value="{$numpolloptions}" size="10" /> {$lang->max_options}</span>
</td>
</tr>'),
		"sid" => "-1",
	);

	$new_thread_subscription  = array(
		"tid" => "0",
		"title" => "new_thread_subscription",
		"template" => $db->escape_string('<tr>
<td class="{$bgcolor}" valign="top"><strong>{$lang->thread_subscription_method}</strong><br />
<span class="smalltext">{$lang->thread_subscription_method_desc}</span>
<br class="clear" />
	<label><input type="radio" name="postoptions[subscriptionmethod]" {$subscribe}value="" style="vertical-align: middle;" /> {$lang->no_subscribe}</label><br />
	<label><input type="radio" name="postoptions[subscriptionmethod]" {$nonesubscribe}value="none" style="vertical-align: middle;" /> {$lang->no_subscribe_notification}</label><br />
	<label><input type="radio" name="postoptions[subscriptionmethod]" {$emailsubscribe}value="email" style="vertical-align: middle;" /> {$lang->instant_email_subscribe}</label><br />
	<label><input type="radio" name="postoptions[subscriptionmethod]" {$pmsubscribe}value="pm" style="vertical-align: middle;" /> {$lang->instant_pm_subscribe}</label><br />
</td>
</tr>'),
		"sid" => "-1",
	);

	$db->insert_query("templates", $new_thread);

	$db->insert_query("templates", $new_thread_modoptions);

	$db->insert_query("templates", $new_thread_postpoll);

	$db->insert_query("templates", $new_thread_subscription);
}

function new_deactivate(){

	global $db;

	$db->delete_query("templates","title = 'new_thread'");

	$db->delete_query("templates","title = 'new_thread_modoptions'");

	$db->delete_query("templates","title = 'new_thread_postpoll'");

	$db->delete_query("templates","title = 'new_thread_subscription'");
}

function new_thread_function()
{
	function cache_forums_select($size=24,$width=230)
	{
		global $forum_cache, $cache;
		
		if(!$forum_cache)
		{
			$forum_cache = $cache->read("forums");

			if(!$forum_cache)
			{
				$cache->update_forums();

				$forum_cache = $cache->read("forums", 1);

			}
		}

		$forum = array();

	    foreach($forum_cache as $forums)
	    {
			
			if($forums['type'] != "c")
			{

				$forum .= "<option value=\"".$forums['fid']."\">".$forums['name']."</option>"; 

			}
	    }
	    $forum_selected = "<select name=\"fid\" size=\"{$size}\" style=\"width: {$width}px\">
		".$forum."</select>";

		return $forum_selected;

	}
}

?>

* in theory though even after minor template changes above in the plugin, one thought is that for someone that has the free time to do so perhaps the plugins global new_thread template should still possibly be considered to be edited further at some point to reflect any further noticeable changes from 1.6 to the 1.8.x newthread template

something else to note:

you might want to change:

in "forums_root_dir"/new.php

eval("\$modoptions = \"".$templates->get("new_thread_modoptions")."\";");

eval("\$subscriptionmethod = \"".$templates->get("new_thread_subscription")."\";");

eval("\$pollbox = \"".$templates->get("new_thread_postpoll")."\";");

eval("\$savedraftbutton = \"".$templates->get("post_savedraftbutton", 1, 0)."\";");

$forumsselected = cache_forums_select();

eval("\$page_new_thread = \"".$templates->get("new_thread", 1, 0)."\";");

output_page($page_new_thread);

to something like:

global $db, $user;

if($mybb->usergroup['canmodcp']) {

eval("\$modoptions = \"".$templates->get("new_thread_modoptions")."\";");

}

if($mybb->user['uid']) {

eval("\$subscriptionmethod = \"".$templates->get("new_thread_subscription")."\";");

eval("\$pollbox = \"".$templates->get("new_thread_postpoll")."\";");

eval("\$savedraftbutton = \"".$templates->get("post_savedraftbutton", 1, 0)."\";");

$forumsselected = cache_forums_select();

eval("\$page_new_thread = \"".$templates->get("new_thread", 1, 0)."\";");

output_page($page_new_thread);

}

if($mybb->user['uid'] == 0) {
    error_no_permission();
}

* primarily because you will note that new.php file is displayed to non registered users, so the edit above stops the new.php from being displayed to non registered non logged in users. oh, and also the modoptions should only be displayed to users than "canmodcp" so the edit above does that.... all while displaying a no permissions page to non registered users....

Thank You So Much Brother 😘 for this.

You don't know what you have just done this. I was trying myself to solve thsese problems and also was successful but not as much you. You did this very well and amazing.
Pages: 1 2