Plugin lock/hide content

Błąd   Założony przez  koloterrorita.

wersja skryptu MyBB: 1.8.7
adres forum:
na czym polega problem (screen, opis, komunikaty, nazwa i wersja wtyczki):
Cześć mam problem z wtyczką "Lock - Sell content in hide tags for newpoints".
Mianowicie, po odpisaniu w wątku plugin powinien odblokować zawartość i w tym problem bo zarejestrowany użytkownik bez odpowiedzi może kliknąć w:
[Obrazek: ukryte.png]

i automatycznie przekieruje na ukryty link.. myślę, że gdzieś jest niedomknięty zawias ale nie mogę znaleźć. może ktoś miał podobny błąd?

ewentualnie czy ktoś może dać namiary na podobny plugin? nie musi być darmowy

pliczki:
lock.php - główny

<?php

function lock_info() {
return array(
'name' => 'Lock',
'description' => 'Hide tags on steroids',
'website' => 'https://mybb.solutions',
'author' => 'Neko',
'authorsite' => 'https://mybb.solutions',
'version' => '1.0',
'compatibility' => '18*',
);
}

if(!defined('IN_ADMINCP')) {
// keep people from using the highlight feature to bypass the tags
$plugins->add_hook('parse_message_start', 'lock_highlight_start');
$plugins->add_hook('parse_message', 'lock_highlight_end');

 // adds a new action method to MyBB.
$plugins->add_hook('global_intermediate', 'lock_purchase');

 // remove hide tags from quotes
 $plugins->add_hook('parse_quoted_message', 'lock_quoted');
}

if(!empty($mybb->input['highlight'])) {
$highlight_replacement = null;
}

if(!class_exists('Shortcodes')) {
   require __DIR__ . '/lock/shortcodes.class.php';
}

function lock_install() {
 global $db;
 require_once __DIR__ . '/lock/core/install.php';
}

function lock_uninstall() {
 global $db;
 require_once __DIR__ . '/lock/core/uninstall.php';
}

function lock_is_installed() {
 global $db;

 // check to see whether we have a settings group
 $query = $db->simple_select("settinggroups", "*", "name='lock'");
 if($db->num_rows($query)) {
   // if there is, return true
   return true;
 }
 return false;
}

function lock_highlight_start($message) {
global $mybb, $replacement;
if(!empty($mybb->input['highlight'])) {
$replacement = substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYXZ", 20)), 0, 20);
$message = str_replace('hide', $replacement, $message);
}
return $message;
}

function lock_highlight_end($message) {
global $mybb, $replacement;

if(!empty($mybb->input['highlight'])) {
$message = str_replace($replacement, 'hide', $message);
}
return Shortcodes::parse($message);
}

function lock_purchase() {
 global $_POST, $mybb, $db;
 require_once __DIR__ . '/lock/core/purchase.php';
}

require_once __DIR__ . '/lock/core/shortcode.php';

function lock_quoted(&$quoted_post) {
$quoted_post['message'] = preg_replace("#\[hide(.*)\[/hide\]#is",'', $quoted_post['message']);
}



?>

purchase.php
<?php

// if the action is not purchase, we don't need to continue.
if($_POST['action'] !== 'purchase') {
 return;
}

// if the purchases functionality has not been enabled, we do not need to continue.
if($mybb->settings['lock_purchases_enabled'] != true) {
 return;
}

$key = $mybb->settings['lock_key'];

// include the pcrypt class, so we can decrypt the sent info.
require_once __DIR__ . '/../pcrypt.php';
$pcrypt = new pcrypt(MODE_ECB, "BLOWFISH", $key);

// convert the sent info back into json data
$json = $pcrypt->decrypt(base64_decode($_POST['info']));

// if the data is indeed json data
if($info = json_decode($json)) {

 // if the data has been successfully turned back into an object.
 if (is_object($info)) {

   // if the cost and post id are not numbers, return an error.
   if(!is_numeric($info->cost) || !is_numeric($info->pid)) {
     error("Something went wrong: NaN");
   }

   // check whether the current user has already unlocked the content
   $query = $db->write_query("SELECT uid,unlocked FROM ".TABLE_PREFIX."posts WHERE pid='{$info->pid}'");
   $post = $db->fetch_array($query);

   $allowed = explode(',', $post['unlocked']);

   if(!is_array($allowed)) {
     $allowed = array();
   }

   if(!in_array($mybb->user['uid'], $allowed)) {

     // user doesn't have it unlocked
     if($mybb->user['newpoints'] < $info->cost) {

       // user does not have enough funds to pay for the item
       error('You do not have enough points to purchase this item.');
     } else {

       // take the points from the user
       newpoints_addpoints($mybb->user['uid'], -$info->cost);

       $mybb->settings['lock_tax'] = $mybb->settings['lock_tax'];

       if(is_numeric($mybb->settings['lock_tax']) && $mybb->settings['lock_tax'] > 0) {
         $tax = $mybb->settings['lock_tax'];
       }

       if(isset($tax) && $tax > 100) {
         $tax = 100;
       }

       if(is_numeric($tax)) {
         $info->cost = $info->cost - ($info->cost / 100 * $tax);
       }

       // give them to the creator of the post
       newpoints_addpoints($post['uid'], $info->cost);

       // add the user to the list of people with access to the content
       $allowed[] = $mybb->user['uid'];
       $allowed = implode(',', $allowed);

       $unlocked = array(
         "unlocked" => $allowed,
       );

       $db->update_query("posts", $unlocked, "pid='{$info->pid}'");
     }
   }

     // now, check that the post actually exists
   $query = $db->simple_select('posts', '*', "pid = '{$info->pid}'");
   if ($db->num_rows($query)) {

     // if it does, redirect the user to the post.
     $post = $db->fetch_array($query);
     $url = $mybb->settings['bburl'].'/'.get_post_link($info->pid).'#pid'.$info->pid;

     header("Location: ".$url);
     exit();

   }
 }
}

?>

shortcode.php
<?php

function lock_hide($params, $content) {
 global $mybb, $post, $templates, $db;

 // if the tag has no content, do nothing.
if (!$content) {
return false;
}

 // return nothing if the print thread page is viewed
 if(empty($post['pid'])) {
   return 'Hidden Content';
 }

 // does the user have to pay for the content?
 if($mybb->settings['lock_purchases_enabled'] == true || (Int)$mybb->settings['lock_default_price'] > 0) {

   // is the pay to view feature allowed in this forum?
   $disabled = explode(',', $mybb->settings['lock_disabled_forums']);
   if(!in_array($post['fid'], $disabled)) {

     // does the content have a price? can the user set the price?
     if(!isset($params['cost']) || !(Bool)$mybb->settings['lock_allow_user_prices']) {

       // if not, do we have a default price?
       if($mybb->settings['lock_default_price'] > 0) {
         $params['cost'] = $mybb->settings['lock_default_price'];
       } else {
         $params['cost'] = null;
       }

     }

     // is the cost an actual number?
     if(is_numeric($params['cost'])) {

       // cost must be valid, because numbers aren't evil.
       $cost = $params['cost'];

       // check to see whether the user hasn't already unlocked the content.
       $allowed = explode(',', $post['unlocked']);
       if(in_array($mybb->user['uid'], $allowed)) {
         $paid = true;
       }

     }

   }

 }

 if(!isset($cost)) {
   // if there's no cost, this must be a "post to view" hide tag

   // check to see whether the user has posted in this thread.
   $query = $db->simple_select('posts', '*', "tid = '{$post['tid']}' AND uid = '{$mybb->user['uid']}'");

   if($db->num_rows($query)) {
     $posted = true;
   }
 }

 // if no title has been set, set a default title.
 if(!isset($params['title'])) {
   $params['title'] = "Hidden Content";
 }

 // if the user is not the OP, and has not been exempt from having hidden content
 if(
   $mybb->user['uid'] != $post['uid'] &&
   !in_array($mybb->user['usergroup'], explode(',', $mybb->settings['lock_exempt']))
 ) {

     // if the user isn't logged in, tell them to login or register.
     if($mybb->user['uid'] == 0) {

       $return = "You must <a href=\"{$mybb->settings['bburl']}/member.php?action=register\">register</a> or <a href=\"{$mybb->settings['bburl']}/member.php?action=login\">login</a> to view this content.";

     // if they are logged in, but the item has a price that they haven't paid yet, tell them how they can pay for it.
     } elseif(isset($cost) && !$paid) {

       // include the pcrypt class, so we can encrypt our data; to keep it safe from spookys.
       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\">
         <button type=\"submit\">Unlock for {$cost} points.</button>
         <input type=\"hidden\" name=\"info\" value=\"{$info}\" />
         <input type=\"hidden\" name=\"action\" value=\"purchase\" />
       </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");
Matslom napisał 13.05.2016, 16:12:
Zapoznaj się z i dodaj informację o autorach spolszczenia oraz używanym silniku do stopki forum.
Całkiem zapomniałem o stopce wybaczcie :F



Użytkownicy przeglądający ten wątek:

1 gości