2013-08-14, 11:23 PM
So I downloaded the hideunstill post plugin from here
http://mods.mybb.com/reviews/hideuntilpost
I did all the edits that people posted
its in prototype.js?ver=1603:5597
POST http://<snipped out>/newreply.php?ajax=1 503 (Service Temporarily Unavailable) prototype.js?ver=1603:1528
Ajax.Request.Class.create.request prototype.js?ver=1603:1528
Ajax.Request.Class.create.initialize prototype.js?ver=1603:1493
(anonymous function) prototype.js?ver=1603:408
klass prototype.js?ver=1603:80
Thread.quickReply thread.js?ver=1603:322
(anonymous function) prototype.js?ver=1603:378
_createResponder.responder
The issue I'm faced with now is when you use the quick reply it doesnt refresh. So I'm looking at the console and when I hit quick reply this error comes up
edited version
http://mods.mybb.com/reviews/hideuntilpost
I did all the edits that people posted
its in prototype.js?ver=1603:5597
POST http://<snipped out>/newreply.php?ajax=1 503 (Service Temporarily Unavailable) prototype.js?ver=1603:1528
Ajax.Request.Class.create.request prototype.js?ver=1603:1528
Ajax.Request.Class.create.initialize prototype.js?ver=1603:1493
(anonymous function) prototype.js?ver=1603:408
klass prototype.js?ver=1603:80
Thread.quickReply thread.js?ver=1603:322
(anonymous function) prototype.js?ver=1603:378
_createResponder.responder
The issue I'm faced with now is when you use the quick reply it doesnt refresh. So I'm looking at the console and when I hit quick reply this error comes up
edited version
<?php
/**
* Author: Sergio Montoya
* Copyright: © 2010 Sergio Montoya
* Website: http://teamlago.com/
**/
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
// Parse messages
$plugins->add_hook("postbit", "hideUntilPost_clear");
$plugins->add_hook("parse_message", "hideUntilPost_code");
// Detect if first reply to post and refresh page
$plugins->add_hook('newreply_do_newreply_end', 'hideUntilPost_donewreply');
// filter quoted messages for tags that user should not see
$plugins->add_hook('newreply_end', 'hideUntilPost_newreply');
// filter fast reply quoted messages
$plugins->add_hook('xmlhttp', 'hideUntilPost_xmlhttp');
function hideUntilPost_info()
{
return array(
"name" => "Links and Attachments lock until post",
"title" => "Links and Attachments lock until post",
"description" => "Will hide all links on posts and remove the attachment box if user has not replied to the thread.",
"website" => "http://www.soportemybb.com",
"author" => "Sergio Montoya",
"authorsite" => "http://www.teamlago.com/foro",
"version" => "1.2",
"guid" => "078dd70346382c953996ebfc3e8edcc7",
"compatibility" => "14*,16*"
);
}
function hideUntilPost_install()
{
// Creating plugin settings
global $db;
$group = array(
"name" => "hideUntilPost_settings",
"title" => "Hides Links and Attachments until Post",
"description" => "Hides Links and Attachments until Post a Post has been made on the thread.",
"disporder" => "50",
"isdefault" => "no",
);
$db->insert_query("settinggroups", $group);
$gid = intval($db->insert_id());
$settings = array(
array(
"name" => "hideUntilPost_link_enabled",
"title" => "Enable/Disable",
"description" => "Hide links until post has been made?",
"optionscode" => "yesno",
"value" => "no",
"disporder" => 1,
"gid" => $gid,
),
array(
"name" => "hideUntilPost_lock_enabled",
"title" => "Enable/Disable",
"description" => "Enable lock bbcode? (Everything inside [lock]...[/lock] will be hiden until post is made)",
"optionscode" => "yesno",
"value" => "no",
"disporder" => 2,
"gid" => $gid,
),
array(
"name" => "hideUntilPost_attach_enabled",
"title" => "Enable/Disable",
"description" => "Hide attachments until post has been made?",
"optionscode" => "yesno",
"value" => "no",
"disporder" => 3,
"gid" => $gid,
),
array(
"name" => "hideUntilPost_gid_exclude",
"title" => "Exclude Groups",
"description" => "Enter the usergroups IDs separated by commas which this plugin should not apply. 0 = No usergroups excluded. (Still won\'t apply for mods and admins)",
"optionscode" => "text",
"value" => 0,
"disporder" => 4,
"gid" => $gid,
),
array(
"name" => "hideUntilPost_fid_exclude",
"title" => "Exclude Forums",
"description" => "Enter the forum IDs separated by commas which this plugin should not apply. 0 = Applies for all forums.",
"optionscode" => "text",
"value" => 0,
"disporder" => 5,
"gid" => $gid,
)
);
foreach($settings as $setting)
$db->insert_query("settings", $setting);
rebuildsettings();
// Create template
$template = array(
"tid" => NULL,
"title" => "hideUntilPost_box",
"template" => "<div style=\"background: #FFF7C0; text-align: left; margin-left: 15px; padding: 13px 20px 13px 45px; border-top: 2px solid #F7D229; border-bottom: 2px solid #F7D229; line-height: 150%; margin-top: 5px; margin-bottom: 5px;\">{\$msg}</div>",
"sid" => "-1"
);
$db->insert_query("templates", $template);
}
function hideUntilPost_is_installed()
{
global $db;
$query = $db->simple_select("templates", "tid", "title = 'hideUntilPost_box'");
if($db->num_rows($query))
{
return true;
}
return false;
}
function hideUntilPost_uninstall()
{
global $db;
$db->delete_query("templates","title = 'hideUntilPost_box'");
$db->delete_query("settinggroups","name = 'hideUntilPost_settings'");
$db->delete_query("settings","name LIKE 'hideUntilPost_%'");
rebuildsettings();
}
function hideUntilPost_count($tid,$uid)
{
global $db;
if(!isset($posts))
{
// Saves in the cache the amount of posts the current user has on the thread
static $posts = 0;
$query = $db->simple_select("posts","COUNT(pid) AS posts","tid='{$tid}' AND uid = '{$uid}'");
$posts = intval($db->fetch_field($query,"posts"));
}
return $posts;
}
function hideUntilPost_validate($fid)
{
global $mybb;
// Check first by usergroups.
if($mybb->user['uid'] != 0 && $mybb->settings['hideUntilPost_gid_exclude'] != 0)
{
$groups = explode(",", $mybb->settings['hideUntilPost_gid_exclude']);
if($mybb->settings['hideUntilPost_gid_exclude'] == 0 || in_array($mybb->user['usergroup'], $groups))
{
// Aww man, can't apply the script to the post.
return false;
}
}
// Usergroup not excluded, so far so good. What about the forum?
if($mybb->settings['hideUntilPost_fid_exclude'] != 0)
{
$fids = explode(",", $mybb->settings['hideUntilPost_fid_exclude']);
if($mybb->settings['hideUntilPost_fid_exclude'] == 0 || in_array($fid, $fids))
{
// Aww man, can't apply the script to the post.
return false;
}
}
// Too bad... hiding content :)
return true;
}
function hideUntilPost_filter(&$msg,$fid,$tid)
{
global $mybb;
if(!hideUntilPost_count($tid,$mybb->user['uid']) && hideUntilPost_validate($fid))
{
if($mybb->settings['hideUntilPost_link_enabled'])
{
$msg = preg_replace("#(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)#is",'',$msg);
}
if($mybb->settings['hideUntilPost_lock_enabled'])
{
$msg = preg_replace("#\[lock\](.*)\[/lock\]#is",'',$msg);
return $msg;
}
}
}
function hideUntilPost_code(&$message) {
global $mybb,$lang,$templates,$thread;
// Will run only if it's being called from newthread.php.
if((THIS_SCRIPT == "showthread.php" || THIS_SCRIPT == "newreply.php") && ($mybb->settings['hideUntilPost_link_enabled'] || $mybb->settings['hideUntilPost_lock_enabled']) && hideUntilPost_validate($thread['fid']) && !is_moderator($thread['fid']))
{
if(!hideUntilPost_count($mybb->input['tid'],$mybb->user['uid']))
{
$lang->load("hideUntilPost");
if($mybb->settings['hideUntilPost_link_enabled'])
{
// Hides links
$msg = $lang->hideUntilPost_link;
eval("\$box = \"".$templates->get("hideUntilPost_box",1,0)."\";");
$message = preg_replace("#<a[^>]*(http|www)(.*)</a>#siU",$box,$message);
}
if($mybb->settings['hideUntilPost_lock_enabled'])
{
// Hides lock bbcode content
$msg = $lang->hideUntilPost_lock;
eval("\$box = \"".$templates->get("hideUntilPost_box",1,0)."\";");
$message = preg_replace("#\[lock\](.*)\[/lock\]#is",$box,$message);
}
$done = true;
}
}
if(!is_moderator())
{
// Parse this one more time. Only mods and admins can see the bbcode.
$message = preg_replace("#\[lock\](.*)\[/lock\]#is",'$1',$message);
return $message;
}
}
function hideUntilPost_clear(&$post)
{
global $mybb,$lang,$attachcache,$templates;
if($mybb->settings['hideUntilPost_attach_enabled'] && is_array($attachcache[$post['pid']]) && $mybb->user['uid'] != $post['uid'] && !is_moderator($post['fid']) && hideUntilPost_validate($post['fid']))
{
if(!hideUntilPost_count($mybb->input['tid'],$mybb->user['uid']))
{
$lang->load("hideUntilPost");
$msg = $lang->hideUntilPost_attach;
eval("\$post['attachments'] = \"".$templates->get("hideUntilPost_box",1,0)."\";");
return $post;
}
}
}
function hideUntilPost_newreply()
{
global $message,$mybb;
hideUntilPost_filter($message,$mybb->input['fid'],$mybb->input['tid']);
}
// After a quick reply, decide to refresh the page or not.
function hideUntilPost_donewreply()
{
global $db,$mybb,$thread;
$redirect = true;
// What has to be done to refresh the page automatically... A huge amount of validation :(
if($mybb->input['ajax'] && !is_moderator($thread['fid']) && hideUntilPost_validate($thread['fid']))
{
if(hideUntilPost_count($thread['tid'],$mybb->user['uid']) === 1)
{
if($mybb->settings['hideUntilPost_attach_enabled'] && $thread['attachmentcount'] > 0)
$redirect = true; //Cmon, attach on first post. Obvious redirect.
else
{
// There's no attachment, but what about links and lock bbcode on first post?
$options = array(
"orderby" => "dateline",
"limit" => array(
"limit" => "1",
"start" => "0"
)
);
$query = $db->simple_select("posts","message","tid = '{$thread['tid']}'",$options);
$message = $db->fetch_field($query,"message");
if($mybb->settings['hideUntilPost_lock_enabled'] && preg_match("#\[lock\](.*)\[/lock\]#is",$msg))
$redirect = true; // We do have a lock bbcode on the first post. Refresh to enable!
elseif($mybb->settings['hideUntilPost_link_enabled'] && preg_match("#<a[^>]*(http|www)(.*)</a>#siU",$msg))
$redirect = true; // We do have a lock bbcode on the first post. Refresh to enable!
}
}
}
if($redirect)
redirect(get_thread_link($thread['tid'], 0, "lastpost"));
}
// Filter quotes
function hideUntilPost_xmlhttp()
{
global $mybb;
if($mybb->input['action'] != 'get_multiquoted')
return;
ob_start();
function hideUntilPost_shutdown()
{
global $message,$multiquoted,$db;
$query = $db->query("SELECT tid,fid FROM ".TABLE_PREFIX."posts WHERE pid = '{$multiquoted[0]}' LIMIT 1");
$addinfo = $db->fetch_array($query);
if(!$message)
return;
ob_end_clean();
ob_start();
hideUntilPost_filter($message,$addinfo['fid'],$addinfo['tid']);
echo $message;
}
register_shutdown_function('hideUntilPost_shutdown');
}
?>