Mybb plugin issue need help updating it for latest version - ℭorruption - Sep 12, 2019
Okay so am very confused atm because am unable to update a old plugin for mybb (php) to a new version of mybb.
The error that I get with the plugin is
SQL
1366 - Incorrect integer value: '' for column 'canjoinreg' at row 1
1366 - Incorrect integer value: '' for column 'alsojoinreg' at row 1
A bit of google search said I need to change sid value to "0" which I did but no changes.
Tried few other things but failed anyone have a idea what I should do to fix this plugin ?
This is the plugin: https://pastebin.com/raw/86ym2bTf
PHP Code
<?php /** * Pick Group on Registration v1.1 * Allow users to join specified groups on the registration page. * * Created by NaXuh * groupregister.php */ // Disallow direct access to this file for security reasons if(!defined("IN_MYBB")) { die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); }
//Admin CP $plugins->add_hook("admin_formcontainer_output_row", "groupregister_row"); $plugins->add_hook('admin_user_groups_edit_commit', 'groupregister_admin_do');
//Registration $plugins->add_hook("member_register_end", "groupregister_register"); $plugins->add_hook("member_do_register_end", "groupregister_registration");
function groupregister_info() { return array( "name" => "Pick Group On Registration", "description" => "Allow users to join specified groups on the registration page.", "website" => "http://community.mybb.com/user-30416.html", "author" => "NaXuh", "authorsite" => "http://community.mybb.com/user-30416.html", "version" => "1.1", "guid" => "97509aa3aec62e807a3f79bcdaaa414f", "compatibility" => "18*" ); }
function groupregister_row($plugina) { global $db, $mybb, $lang, $user, $form, $form_container, $usergroup; $lang->load('groupregister'); if($plugina['title'] == "Moderation/Administration Options") { $gr1 = array( $form->generate_check_box('canjoinreg', 1, $lang->groupregister_admin_can_join, array('checked' => $mybb->input['canjoinreg'])), $form->generate_check_box('alsojoinreg', 1, $lang->groupregister_admin_also_join, array('checked' => $mybb->input['alsojoinreg'])), ); $form_container->output_row($lang->groupregister_admin_title, '', '<div class="group_settings_bit">'.implode('</div><div class="group_settings_bit">', $gr1).'</div>'); } }
function groupregister_admin_do() { global $mybb, $updated_group; $updated_group['canjoinreg'] = $mybb->input['canjoinreg']; $updated_group['alsojoinreg'] = $mybb->input['alsojoinreg']; }
function groupregister_register() { global $mybb, $db, $lang, $groupregister, $selectboxes, $templates; $lang->load('groupregister'); $query = $db->simple_select("usergroups", "*", "canjoinreg='1'"); if($db->num_rows($query) != 0) { $selectboxes = '<select name="grouptojoin" id="grouptojoin">'; while($result=$db->fetch_array($query)) { $selectboxes .= '<option value="' . $result['title'] . '">' . $result['title'] . '</option>'; } $selectboxes .= '</select>'; eval("\$groupregister = \"".$templates->get("groupregister")."\";"); } }
function groupregister_registration() { global $mybb, $db; if($mybb->input['grouptojoin'] != "") { $groupname = $db->escape_string($mybb->input['grouptojoin']); $query = $db->simple_select("usergroups", "*", "title='$groupname'"); $groupid = $db->fetch_field($query, "gid"); if($groupid != 4) { $groupreg = $db->fetch_field($query, "alsojoinreg"); $updated_record['usergroup'] = $db->escape_string($groupid); if($groupreg == 1) { $update_record['additionalgroups'] = 2; } $db->update_query('users', $updated_record, "username='".$db->escape_string($mybb->input['username'])."'"); } } }
function groupregister_activate() { global $mybb, $lang, $db; $lang->load('groupregister'); $new_template['groupregister'] = '<br /> <fieldset class="trow2"> <legend><strong>{$lang->groupregister_title}</strong></legend> <table cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}"> <tr> <td colspan="2"><span class="smalltext"><label for="grouptojoin">{$lang->groupregister_desc}</label></span></td> </tr> <tr> <td colspan="2"> {$selectboxes} </td> </tr></table></fieldset>'; foreach($new_template as $title => $template) { $new_template = array('title' => $db->escape_string($title), 'template' => $db->escape_string($template), 'sid' => '-1', 'version' => '16', 'dateline' => TIME_NOW); $db->insert_query('templates', $new_template); } include MYBB_ROOT."/inc/adminfunctions_templates.php"; find_replace_templatesets("member_register", "#".preg_quote("{\$referrer}")."#i", "{\$referrer}\r\n{\$groupregister}"); }
function groupregister_deactivate() { global $mybb, $db; include MYBB_ROOT."/inc/adminfunctions_templates.php"; $db->delete_query('templates', 'title=\'groupregister\''); find_replace_templatesets("member_register", "#".preg_quote("\r\n{\$groupregister}")."#i", "", 0); }
function groupregister_install() { global $mybb, $db; $db->write_query("ALTER TABLE `".TABLE_PREFIX."usergroups` ADD `canjoinreg` INT(1) NOT NULL DEFAULT '0';"); $db->write_query("ALTER TABLE `".TABLE_PREFIX."usergroups` ADD `alsojoinreg` INT(1) NOT NULL DEFAULT '0';"); }
function groupregister_is_installed() { global $db; if($db->field_exists("canjoinreg", "usergroups") && $db->field_exists("alsojoinreg", "usergroups")) { return true; } return false; }
function groupregister_uninstall() { global $mybb, $db; $db->write_query("ALTER TABLE `".TABLE_PREFIX."usergroups` DROP `canjoinreg`;"); $db->write_query("ALTER TABLE `".TABLE_PREFIX."usergroups` DROP `alsojoinreg`;"); } ?>
RE: Mybb plugin issue need help updating it for latest version - Lives - Sep 14, 2019
Found this on some foreign forum:
PHP Code
<?php $updated_group['canjoinreg'] = $mybb->input['canjoinreg']; $updated_group['alsojoinreg'] = $mybb->input['alsojoinreg'];
Change to:
PHP Code
<?php $updated_group['canjoinreg'] = $mybb->get_input('canjoinreg', MyBB::INPUT_INT); $updated_group['alsojoinreg'] = $mybb->get_input('alsojoinreg', MyBB::INPUT_INT);
because MySQL5.7 otherwise complains.
—————————————————————————————————————————————————————————
You can just Copy & Paste this (Updated Code):
PHP Code
<?php /** * Pick Group on Registration v1.1 * Allow users to join specified groups on the registration page. * * Created by NaXuh * groupregister.php */ // Disallow direct access to this file for security reasons if(!defined("IN_MYBB")) { die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); }
//Admin CP $plugins->add_hook("admin_formcontainer_output_row", "groupregister_row"); $plugins->add_hook('admin_user_groups_edit_commit', 'groupregister_admin_do');
//Registration $plugins->add_hook("member_register_end", "groupregister_register"); $plugins->add_hook("member_do_register_end", "groupregister_registration");
function groupregister_info() { return array( "name" => "Pick Group On Registration", "description" => "Allow users to join specified groups on the registration page.", "website" => "http://community.mybb.com/user-30416.html", "author" => "NaXuh", "authorsite" => "http://community.mybb.com/user-30416.html", "version" => "1.1", "guid" => "97509aa3aec62e807a3f79bcdaaa414f", "compatibility" => "18*" ); }
function groupregister_row($plugina) { global $db, $mybb, $lang, $user, $form, $form_container, $usergroup; $lang->load('groupregister'); if($plugina['title'] == "Moderation/Administration Options") { $gr1 = array( $form->generate_check_box('canjoinreg', 1, $lang->groupregister_admin_can_join, array('checked' => $mybb->input['canjoinreg'])), $form->generate_check_box('alsojoinreg', 1, $lang->groupregister_admin_also_join, array('checked' => $mybb->input['alsojoinreg'])), ); $form_container->output_row($lang->groupregister_admin_title, '', '<div class="group_settings_bit">'.implode('</div><div class="group_settings_bit">', $gr1).'</div>'); } }
function groupregister_admin_do() { global $mybb, $updated_group; $updated_group['canjoinreg'] = $mybb->get_input('canjoinreg', MyBB::INPUT_INT); $updated_group['alsojoinreg'] = $mybb->get_input('alsojoinreg', MyBB::INPUT_INT); }
function groupregister_register() { global $mybb, $db, $lang, $groupregister, $selectboxes, $templates; $lang->load('groupregister'); $query = $db->simple_select("usergroups", "*", "canjoinreg='1'"); if($db->num_rows($query) != 0) { $selectboxes = '<select name="grouptojoin" id="grouptojoin">'; while($result=$db->fetch_array($query)) { $selectboxes .= '<option value="' . $result['title'] . '">' . $result['title'] . '</option>'; } $selectboxes .= '</select>'; eval("\$groupregister = \"".$templates->get("groupregister")."\";"); } }
function groupregister_registration() { global $mybb, $db; if($mybb->input['grouptojoin'] != "") { $groupname = $db->escape_string($mybb->input['grouptojoin']); $query = $db->simple_select("usergroups", "*", "title='$groupname'"); $groupid = $db->fetch_field($query, "gid"); if($groupid != 4) { $groupreg = $db->fetch_field($query, "alsojoinreg"); $updated_record['usergroup'] = $db->escape_string($groupid); if($groupreg == 1) { $update_record['additionalgroups'] = 2; } $db->update_query('users', $updated_record, "username='".$db->escape_string($mybb->input['username'])."'"); } } }
function groupregister_activate() { global $mybb, $lang, $db; $lang->load('groupregister'); $new_template['groupregister'] = '<br /> <fieldset class="trow2"> <legend><strong>{$lang->groupregister_title}</strong></legend> <table cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}"> <tr> <td colspan="2"><span class="smalltext"><label for="grouptojoin">{$lang->groupregister_desc}</label></span></td> </tr> <tr> <td colspan="2"> {$selectboxes} </td> </tr></table></fieldset>'; foreach($new_template as $title => $template) { $new_template = array('title' => $db->escape_string($title), 'template' => $db->escape_string($template), 'sid' => '-1', 'version' => '16', 'dateline' => TIME_NOW); $db->insert_query('templates', $new_template); } include MYBB_ROOT."/inc/adminfunctions_templates.php"; find_replace_templatesets("member_register", "#".preg_quote("{\$referrer}")."#i", "{\$referrer}\r\n{\$groupregister}"); }
function groupregister_deactivate() { global $mybb, $db; include MYBB_ROOT."/inc/adminfunctions_templates.php"; $db->delete_query('templates', 'title=\'groupregister\''); find_replace_templatesets("member_register", "#".preg_quote("\r\n{\$groupregister}")."#i", "", 0); }
function groupregister_install() { global $mybb, $db; $db->write_query("ALTER TABLE `".TABLE_PREFIX."usergroups` ADD `canjoinreg` INT(1) NOT NULL DEFAULT '0';"); $db->write_query("ALTER TABLE `".TABLE_PREFIX."usergroups` ADD `alsojoinreg` INT(1) NOT NULL DEFAULT '0';"); }
function groupregister_is_installed() { global $db; if($db->field_exists("canjoinreg", "usergroups") && $db->field_exists("alsojoinreg", "usergroups")) { return true; } return false; }
function groupregister_uninstall() { global $mybb, $db; $db->write_query("ALTER TABLE `".TABLE_PREFIX."usergroups` DROP `canjoinreg`;"); $db->write_query("ALTER TABLE `".TABLE_PREFIX."usergroups` DROP `alsojoinreg`;"); } ?>
—————————————————————————————————————————————————————————
Let me know if it works out for you!
RE: Mybb plugin issue need help updating it for latest version - ℭorruption - Sep 15, 2019
(Sep 14, 2019 11:24 AM)Lives Wrote: Let me know if it works out for you!
Hey there,
Thank you for the reply but this did not work.
RE: Mybb plugin issue need help updating it for latest version - ℭorruption - Sep 16, 2019
Turns out my hosting is causing all the mysql issues.
ilogic to set a value of an integer and autoincrement field, so you can not put values in there the system automatically assign it.
So it was due to hosting having some type of restrictions with this values.
|