Password Generator Plugin - Template Help
#1
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:

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....)
Do NOT pm me for support on ANY of my plugins
DO pm me if you got suggestions for existing ones (although posting in the proper thread is preferred), or suggestions/ideas for new plugins (keep in mind I'm an amateur but not necessarily a beginner.)
Reply
#2
Quote:1. How do I execute a function I create when the button is pressed

Use either the jQuery library which is built in or standard javascript. Look up DOM Events or Mouse Events.
Reply
#3
(02-16-2015, 05:49 PM)dragonexpert Wrote:
Quote:1. How do I execute a function I create when the button is pressed

Use either the jQuery library which is built in or standard javascript. Look up DOM Events or Mouse Events.

I know about dom events, but I'd rather use a custom php function because I can use some of the string function like explode(), implode(), and other functins which randomize values. Would implementing a form element work (I was hoping not to have to implement one though).

I cannot seem to get variable substitution to work? How do you substitute variables in templates? I looked at the doc, but it isn't working.
Do NOT pm me for support on ANY of my plugins
DO pm me if you got suggestions for existing ones (although posting in the proper thread is preferred), or suggestions/ideas for new plugins (keep in mind I'm an amateur but not necessarily a beginner.)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)