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
(2021-01-30, 01:16 AM)PARADOXP Wrote: [ -> ]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.


No worries, I am sorry that I did not have much free-time to look at this much further, but, I am glad to hear that it got it sorted out for you. Smile

oh, one other thing I had noticed on just a thought, but that, perhaps:

<td align="left" width="60%">

and:

<td align="right" valign="top" width="40%">


might perhaps change to:

<td align="left" width="80%">

<td align="right" valign="top" width="20%">

ie:

[Image: New-Thread.png]


note: changed in previous attachment 1.1 https://community.mybb.com/attachment.php?aid=43707 * also corrected the existing misspelling of "right" ex:"rihgt" that caused issue with the 40%er

Though in this one "1.1.2" I kinda changed the layout a lil  and added prefix selector and posticons [attachment=43710]

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


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

<?php
/**
 * MyBB 1.8
 * 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.2
 *
 */

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.2",
		"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}
      {$moderation_notice}
      <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" colspan="2"><strong>{$lang->post_new_thread}</strong></td>
            </tr>
            {$loginbox}
            <tr>
               <td class="trow2" width="20%"><strong>{$lang->thread_subject}</strong></td>
               <td class="trow2">{$prefixselect} <input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
            </tr>
            {$posticons} 
            <tr>
               <td class="trow2" valign="top"><strong>{$lang->your_message}</strong><br /><span style="font-size:18px"><strong>{$lang->forumbit_forum}:</strong></span><br />{$forumsselected}</td>
               <td class="trow2" valign="top">
                  <textarea name="message" id="message" rows="20" cols="70" tabindex="2" style="height: 540px;">{$message}</textarea>
                  {$codebuttons}
               </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="trow1" valign="top"><strong>{$lang->post_options}</strong></td>
   <td class="trow1"><span class="smalltext">
      <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="trow1" valign="top"><strong>{$lang->mod_options}</strong></td>
   <td class="trow1"><span class="smalltext">
      <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="trow1" valign="top"><strong>{$lang->poll}</strong><br /><span class="smalltext">{$lang->poll_desc}</span></td>
   <td class="trow1">
      <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="trow1" valign="top"><strong>{$lang->thread_subscription_method}</strong><br /><span class="smalltext">{$lang->thread_subscription_method_desc}</span></td>
   <td class="trow1"><span class="smalltext">
      <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></span>
   </td>
</tr>'),
		"sid" => "-1",
	);

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

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

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

	$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 1.8
 * 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.2
 *
 */

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("{$lang->nav_newthread}", "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();

}

?>
and also you forgot to add {$prefixselect} 😄

(2021-01-30, 01:46 AM)censor_deeznutz Wrote: [ -> ]
(2021-01-30, 01:16 AM)PARADOXP Wrote: [ -> ]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.


No worries, I am sorry that I did not have much free-time to look at this much further, but, I am glad to hear that it got it sorted out for you. Smile

oh, one other thing I had noticed on just a thought, but that, perhaps:

<td align="left" width="60%">

and:

<td align="right" valign="top" width="40%">


might perhaps change to:

<td align="left" width="80%">

<td align="right" valign="top" width="20%">

ie:

[Image: New-Thread.png]


note: changed in previous attachment https://community.mybb.com/attachment.php?aid=43707 * also corrected the existing misspelling of "right" ex:"rihgt" that caused issue with the 40%er

Thanks a lot Brother.
(2021-01-30, 05:36 AM)PARADOXP Wrote: [ -> ]and also you forgot to add {$prefixselect} 😄



incorrect, the original author Edson did not include that for a reason.... becuase this bypass is not predefined or attached fid specific and the entirety of the newthread.php is based on predefined /attached fid..., so pulling those from newthread would not work and such functions would have to be completely rewritten specific for the new.php usages to omit fid in the functions as the existing new.php and plugin templates that the author created was intended to write content and then select what forum to post it to from a list of fids not on the contrary have a predefined / attached fid and then post to such..., things like loginbox is simple to add without much more than simply copying that into new.php file and then adding such to the template but as far as posticons, prefixes, etc, etc, those would have to be coded similar to the newthread.php but specific to new.php and not reliant of fid as the entire objective of the plugin is to bypass newthreads reliance on specific fid and have an input to output to then a selected fid..., if that makes sense and is why I assume with this simple plugin edson most likely did not want to spend the time to painstakingly write a bunch of functions for new.php posticons, prefixselect, etc, etc.... also since my replies were simply in regards to the request to get the existing plugin to work again minus the mentioned errors and such as explained..., and the only other change was to make sure the plugin was not open to guests by adding permissions because in theory as is the plugin if guest posting was enabled and captcha for reg and posting was disabled could then view, use and post from the plugin and well, umm, yeah..., anyhoo, my objective was just that to fix the noted errors in request and add minor perms and only that and not to actually re-write the plugin to do things the original author had not intended it to do as my "free" time is rather limited and such goes beyond the scope of the initial request.
Yes you are right i tried to pull those features from newthread.php , but nothing just happened...

anyway here is one more plugin that allows members to sow a quick thread making editor in forumdisplay like quick thread reply in showthread.



can we adapt the prefix selection feature just like ZiNgA BuRgA did in this plugin ? 
(2021-01-31, 02:12 AM)PARADOXP Wrote: [ -> ]can we adapt the prefix selection feature just like ZiNgA BuRgA did in this plugin ? 

don't need that...

you would just modify you existing snippets from the previous replies as follows:


in forum(root)/new.php

find:

$plugins->run_hooks('new_thread_start');

add directly after:

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


in forum(root)/inc/plugins/new.php make sure that:

{$prefixselect}

is placed:
{$prefixselect} <input type="text" class="textbox"

or you can note that:

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

and 1.1.2
[Image: Post-a-new-Thread-2.png]


variants already have the selector, loginbox, posticons, etc, etc.. and perhaps opt for one of them... (only things that I did not focus on was smilieinsertor, because well, it doesnt need to be done for this due to layout and also due to the fact that there are smilies on the toolbar so smilies are still present, second thing I did not focus on was attachbox and I am not planning on it for this request as primarily one can simply input everything and then if they want attachments..., simply select preview thread as that will redirect to newthread with all the inputted details thus showing you the attachbox on newthread preview and will have to suffice for now as I do not have the free time nor desire to implement attachbox on this...)
Pages: 1 2