require_once __DIR__ . '/../pcrypt.php'; $key = $mybb->settings['lock_key']; $pcrypt = new pcrypt(MODE_ECB, "BLOWFISH", $key); // place the info we need, into an array $info = array('pid' => $post['pid'], 'cost' => $cost); // encode the information as json, for safe transit $info = json_encode($info); // encrypt the json, and encode it as base64; so it can be submitted in a form. $info = base64_encode($pcrypt->encrypt($info)); // build the return button. $return = "<form method=\"post\">\n <button type=\"submit\">Unlock for {$cost} points.</button>\n <input type=\"hidden\" name=\"info\" value=\"{$info}\" />\n <input type=\"hidden\" name=\"action\" value=\"purchase\" />\n </form>"; // if the user doesn't need to pay, but hasn't posted } elseif (!$paid && !$posted) { // tell them to reply to the thread. $return = "You must reply to this thread to view this content."; // all is good. } else { // give them the content. $return = $content; } // bypass the hide tags. } else { // give them the content $return = $content; } eval("\$return = \"" . $templates->get("lock_wrapper") . "\";"); return $return; } // add the hide tag if the shortcodes plugin has been installed. Shortcodes::add("hide", "lock_hide");