2015-02-16, 04:21 PM
Ok, so I'm making a password generator plugin that lets users generate passwords when they want, but I am a bit stuck as to what to do now:
Few questions:
1. How do I execute a function I create when the button is pressed
2. What would be the simplest way for me to link to the page
3. How do I fix it where the header info is what I want, but consistent with other pages? (In the second eval, I tried copy/paste template markup from the default to the template and eval my template, but that didn't seem to work....)
function password_generator_activate() {
global $db;
$template = "
<body>
<div>
<p>Click the following button to generate a password:</p>
<p><input type='submit' id='ircher_button_generate_password' value='Generate Password' /></p>
<p>Generated Password: <strong>{$password_generator}</strong></p>
</div>
</body>
</html>";
$template_insert_array = array(
'title' => 'ircher_password_generator_template',
'template' => $db->escape_string($template),
'sid' => '-1',
'version' => '1.0',
'dateline' => time()
);
$db->insert_query('templates', $template_insert_array);
}
function password_generator_page() {
global $mybb, $templates, $lang, $header, $headerinclude, $footer;
if ($mybb->get_input( 'action', MyBB::INPUT_STRING) == 'password_generator_view') {
add_breadcrumb( 'Password Generator', "misc.php?action=password_generator_view");
$password_generator = '';
eval( '$sections = "'.$templates->get( 'ircher_password_generator_template').'";');
eval( "\$page = \"".$templates->get('misc_help')."\";");
output_page( $page );
}
Few questions:
1. How do I execute a function I create when the button is pressed
2. What would be the simplest way for me to link to the page
3. How do I fix it where the header info is what I want, but consistent with other pages? (In the second eval, I tried copy/paste template markup from the default to the template and eval my template, but that didn't seem to work....)