Mine sisusse
Otsi siit
  • Rohkem valikuid...
Otsi tulemusi mis sisaldab...
Otsi tulemusi...

Küsimus

6 vastust sellele küsimusele

Soovitatud postitused

  • 0
Author of the topic Postitas (muudetud)

lisatud.

 

Plugin ise on selline

 

/*

Plugin Thanks 3.9.1
(c) 2008-2011 by Huji Lee, SaeedGh (SaeehGhMail@Gmail.com)
Last edit: 11-26-2011

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see .

*/

if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.");
}

if(isset($GLOBALS['templatelist']))
{
$GLOBALS['templatelist'] .= ", thanks_postbit_count";
}

$plugins->add_hook("postbit", "thx");
$plugins->add_hook("xmlhttp", "do_action");
$plugins->add_hook("showthread_start", "direct_action");
$plugins->add_hook("class_moderation_delete_post", "deletepost_edit");
$plugins->add_hook('admin_tools_action_handler', 'thx_admin_action');
$plugins->add_hook('admin_tools_menu', 'thx_admin_menu');
$plugins->add_hook('admin_tools_permissions', 'thx_admin_permissions');
$plugins->add_hook('admin_load', 'thx_admin');

function thx_info()
{
return array(
	'name'			=>	' Thanks',
	'description'	=>	'Add a Thanks button to user posts.',
	'website'		=>	'http://www.mybb.com',
	'author'		=>	'Huji Lee, SaeedGh',
	'authorsite'	=>	'mailto:SaeedGhMail@Gmail.com',
	'version'		=>	'3.9.1',
	'guid'		    =>	'd82cb3ceedd7eafa8954449cd02a449f',
       'compatibility' =>	'14*,16*'
);
}


function thx_install()
{
global $db;

$db->query("CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."thx ( 
	txid INT UNSIGNED NOT NULL AUTO_INCREMENT, 
	uid int(10) UNSIGNED NOT NULL, 
	adduid int(10) UNSIGNED NOT NULL, 
	pid int(10) UNSIGNED NOT NULL, 
	time bigint(30) NOT NULL DEFAULT '0', 
	PRIMARY KEY (`txid`), 
	INDEX (`adduid`, `pid`, `time`) 
	);"
);

if(!$db->field_exists("thx", "users"))
{
	$sq[] = "ALTER TABLE ".TABLE_PREFIX."users ADD `thx` INT NOT NULL, ADD `thxcount` INT NOT NULL, ADD `thxpost` INT NOT NULL";
}
elseif (!$db->field_exists("thxpost", "users"))		
{
	$sq[] = "ALTER TABLE ".TABLE_PREFIX."users ADD `thxpost` INT NOT NULL";
}

if($db->field_exists("thx", "posts"))
{
	$sq[] = "ALTER TABLE ".TABLE_PREFIX."posts DROP thx";
}

if(!$db->field_exists("pthx", "posts"))
{
	$sq[] = "ALTER TABLE ".TABLE_PREFIX."posts ADD `pthx` INT(10) NOT NULL DEFAULT '0'";
}

if(is_array($sq))
{
	foreach($sq as $q)
	{
		$db->query($q);
	}
}
}


function thx_is_installed()
{
global $db;
if($db->field_exists('thxpost', "users"))
{
	return true;
}
return false;
}


function thx_activate()
{
global $db;

//Update from v3.8
$thx_tbl_keys = $db->query("SHOW KEYS FROM ".TABLE_PREFIX."thx WHERE Key_name='adduid'");

if(!$db->fetch_field($thx_tbl_keys, "Key_name"))
{
	$db->query("ALTER TABLE ".TABLE_PREFIX."thx ADD INDEX (`adduid`, `pid`, `time`)");
}

//Adding templates
require MYBB_ROOT."inc/adminfunctions_templates.php";

if(!find_replace_templatesets("postbit", '#'.preg_quote('{$seperator}').'#', '{$post[\'thxdsp_inline\']}{$seperator}{$post[\'thxdsp_outline\']}'))
{
	find_replace_templatesets("postbit", '#button_delete_pm(.*)(.*)#is', 'button_delete_pm$1{\$post[\'thxdsp_inline\']}$2{$post[\'thxdsp_outline\']}');
}
find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'button_quote\']}').'#', '{$post[\'button_quote\']}{$post[\'thanks\']}');
find_replace_templatesets("postbit_classic", '#button_delete_pm(.*)(.*)#is', 'button_delete_pm$1{\$post[\'thxdsp_inline\']}$2{$post[\'thxdsp_outline\']}');
find_replace_templatesets("postbit_classic", '#'.preg_quote('{$post[\'button_quote\']}').'#', '{$post[\'button_quote\']}{$post[\'thanks\']}');

find_replace_templatesets("headerinclude", "#".preg_quote('{$newpmmsg}').'#',
	'{$newpmmsg}');

$templatearray = array(
	'title' => 'thanks_postbit_count',
	'template' => "{\$lang->thx_thank} {\$post[\'thank_count\']}

{\$post[\'thanked_count\']}
",
	'sid' => '-1',
	);
$db->insert_query("templates", $templatearray);

$templatearray = array(
	'title' => 'thanks_postbit_inline',
	'template' => "{\$lang->thx_givenby} \$entries",
	'sid' => '-1',
	);	
$db->insert_query("templates", $templatearray);

$templatearray = array(
	'title' => 'thanks_postbit_inline_classic',
	'template' => "{\$lang->thx_givenby}\$entries",
	'sid' => '-1',
	);	
$db->insert_query("templates", $templatearray);

$templatearray = array(
	'title' => 'thanks_postbit_outline',
	'template' => "</pre><table border='\"0\"' cellspacing='\"0\"' cellpadding='\"0\"' width='\"100%\"' id="\"thx{\$post[\'pid\']}\"" style='\"{\$display_style};margin-top:5px;\"'>
settings[\'bburl\']}/images/rose.gif\" align=\"absmiddle\" />  {\$lang->thx_givenby}\$entries
</table>",<br>	'sid' => '-1',<br>	);<br>$db->insert_query("templates", $templatearray);<br><br>$thx_group = array(<br>	"name"			=> "Thanks",<br>	"title"			=> "Thanks",<br>	"description"	=> "Displays thank you note below each post.",<br>	"disporder"		=> "3",<br>	"isdefault"		=> "1"<br>);	<br>$db->insert_query("settinggroups", $thx_group);<br>$gid = $db->insert_id();<br><br>$thx[]= array(<br>	"name"			=> "thx_active",<br>	"title"			=> "Activate/Deactivate this plugin",<br>	"description"	=> "Activate or deactivate plugin but no delete table",<br>	"optionscode" 	=> "onoff",<br>	"value"			=> '1',<br>	"disporder"		=> '1',<br>	"gid"			=> intval($gid),<br>);<br><br>$thx[] = array(<br>	"name"			=> "thx_count",<br>	"title"			=> "Show count thanks",<br>	"description"	=> "Show count thanks in any post",<br>	"optionscode" 	=> "onoff",<br>	"value"			=> '1',<br>	"disporder"		=> '2',<br>	"gid"			=> intval($gid),<br>);<br><br>$thx[] = array(<br>	"name"			=> "thx_del",<br>	"title"			=> "Users can remove their thanks",<br>	"description"	=> "Every one can delete his thanks",<br>	"optionscode" 	=> "onoff",<br>	"value"			=> '1',<br>	"disporder"		=> '3',<br>	"gid"			=> intval($gid),<br>);<br><br>$thx[] = array(<br>	"name"			=> "thx_hidemode",<br>	"title"			=> "Show date on mouse over",<br>	"description"	=> "Show date of thanks just when mouse is over it",<br>	"optionscode" 	=> "onoff",<br>	"value"			=> '1',<br>	"disporder"		=> '4',<br>	"gid"			=> intval($gid),<br>);<br><br>$thx[] = array(<br>	"name"			=> "thx_autolayout",<br>	"title"			=> "Auto detect layout",<br>	"description"	=> "Detect postbit layout and try to correct related HTML code! (just works if \"Separate table\" is ON)",<br>	"optionscode" 	=> "onoff",<br>	"value"			=> '1',<br>	"disporder"		=> '5',<br>	"gid"			=> intval($gid),<br>);<br><br>$thx[] = array(<br>	"name"			=> "thx_outline",<br>	"title"			=> "Separate table",<br>	"description"	=> "If you want to show thanks between of tow post (not in end of a post), switch this option on.",<br>	"optionscode"	=> "onoff",<br>	"value"			=> '1',<br>	"disporder"		=> '6',<br>	"gid"			=> intval($gid),<br>);<br><br>foreach($thx as $t)<br>{<br>	$db->insert_query("settings", $t);<br>}<br><br>rebuild_settings();<br>}<br><br><br>function thx_deactivate()<br>{<br>global $db;<br>require '../inc/adminfunctions_templates.php';<br><br>find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'thxdsp_inline\']}').'#', '', 0);<br>find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'thxdsp_outline\']}').'#', '', 0);<br>find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'thanks\']}').'#', '', 0);<br>find_replace_templatesets("postbit_classic", '#'.preg_quote('{$post[\'thxdsp_inline\']}').'#', '', 0);<br>find_replace_templatesets("postbit_classic", '#'.preg_quote('{$post[\'thxdsp_outline\']}').'#', '', 0);<br>find_replace_templatesets("postbit_classic", '#'.preg_quote('{$post[\'thanks\']}').'#', '', 0);<br>find_replace_templatesets("headerinclude", "#".preg_quote('<script type="text/javascript" src="jscripts/thx.js"></script>').'#', '', 0);<br><br>$db->delete_query("settings", "name IN ('thx_active', 'thx_count', 'thx_del', 'thx_hidemode', 'thx_autolayout', 'thx_outline')");<br>$db->delete_query("settinggroups", "name='Thanks'");<br>$db->delete_query("templates", "title='thanks_postbit_count'");<br>$db->delete_query("templates", "title='thanks_postbit_inline'");<br>$db->delete_query("templates", "title='thanks_postbit_inline_classic'");<br>$db->delete_query("templates", "title='thanks_postbit_outline'");<br><br>rebuild_settings();<br>}<br><br><br>function thx_uninstall()<br>{<br>global $db;<br><br>/*$db->query("drop TABLE ".TABLE_PREFIX."thx");*/<br><br>if($db->field_exists("thx", "users"))<br>{<br>	$db->query("ALTER TABLE ".TABLE_PREFIX."users DROP thx, DROP thxcount, DROP thxpost");<br>}<br><br>if($db->field_exists("pthx", "posts"))<br>{<br>	$db->query("ALTER TABLE ".TABLE_PREFIX."posts DROP pthx");<br>}<br>}<br><br><br>function thx(&$post) <br>{<br>global $db, $mybb, $lang ,$session, $theme, $altbg, $templates, $thx_cache;<br><br>if(!$mybb->settings['thx_active'] || !empty($session->is_spider))<br>{<br>	return false;<br>}<br><br>$lang->load("thx");<br><br>if($b = $post['pthx'])<br>{<br>	$entries = build_thank($post['pid'], $b);<br>}<br>else <br>{<br>	$entries = "";<br>}<br><br>	if($mybb->user['uid'] != 0 && $mybb->user['uid'] != $post['uid']) <br>{<br>	if(!$b)<br>	{<br>		$post['thanks'] = "<a id="\"a{$post['pid']}\"" onclick='\"javascript:return' thx href="%5C%22showthread.php?action=thank&tid=%7B%24post%5B'tid'%5D%7D&pid=%7B%24post%5B'pid'%5D%7D%5C%22" rel="">
settings['bburl']}/{$theme['imgdir']}/postbit_thx.gif\" border=\"0\" alt=\"$lang->thx_main\" title=\"$lang->thx_main\" id=\"i{$post['pid']}\" /></a>";<br>	}<br>	else if($mybb->settings['thx_del'] == "1")<br>	{<br>		$post['thanks'] = "<a id="\"a{$post['pid']}\"" onclick='\"javascript:return' rthx href="%5C%22showthread.php?action=remove_thank&tid=%7B%24post%5B'tid'%5D%7D&pid=%7B%24post%5B'pid'%5D%7D%5C%22" rel="">
settings['bburl']}/{$theme['imgdir']}/postbit_rthx.gif\" border=\"0\" alt=\"$lang->thx_remove\" title=\"$lang->thx_remove\" id=\"i{$post['pid']}\" /></a>";<br>	}<br>	else<br>	{<br>		$post['thanks'] = "";<br>	}<br>}<br><br>$display_style = $entries ?  "" : "display:none; border:0;";<br>$playout = $mybb->settings['postlayout'];<br><br>if(!$mybb->settings['thx_outline'])<br>{<br>	eval("\$post['thxdsp_inline'] .= \"".$templates->get("thanks_postbit_inline")."\";");<br><br>	if($mybb->settings['thx_autolayout'] && $playout == "classic")<br>	{<br>		eval("\$post['thxdsp_inline'] .= \"".$templates->get("thanks_postbit_inline_classic")."\";");<br>	}<br>}<br>else<br>{	<br>	eval("\$post['thxdsp_outline'] .= \"".$templates->get("thanks_postbit_outline")."\";");<br>}<br><br>if($mybb->settings['thx_count'] == "1")<br>{<br>	if(!isset($thx_cache['postbit'][$post['uid']]))<br>	{<br>		$post['thank_count'] = $post['thx'];<br>		$post['thanked_count'] = $lang->sprintf($lang->thx_thanked_count, $post['thxcount'], $post['thxpost']);<br>		eval("\$x = \"".$templates->get("thanks_postbit_count")."\";");<br>		$thx_cache['postbit'][$post['uid']] = $x;<br>	}<br><br>	$post['user_details'] .= $thx_cache['postbit'][$post['uid']];<br>}<br>}<br><br>function do_action()<br>{<br>global $mybb, $lang, $theme;<br><br>if(($mybb->input['action'] != "thankyou"  &&  $mybb->input['action'] != "remove_thankyou") || $mybb->request_method != "post")<br>{<br>	return false;<br>}<br><br>if(file_exists($lang->path."/".$lang->language."/thx.lang.php"))	<br>{<br>	$lang->load("thx");<br>}<br>else <br>{<br>	$l = $lang->language;<br>	$lang->set_language();<br>	$lang->load("thx");<br>	$lang->set_language($l);<br>}<br><br>$pid = intval($mybb->input['pid']);<br><br>if ($mybb->input['action'] == "thankyou" )<br>{<br>	do_thank($pid);<br>}<br>else if($mybb->settings['thx_del'] == "1")<br>{<br>	del_thank($pid);<br>}<br><br>$nonead = 0;<br>$list = build_thank($pid, $nonead);<br>header('Content-Type: text/xml');<br>$output = "<thankyou>

".($list ? "1" : "0")."
{$mybb->settings['bburl']}/{$theme['imgdir']}/";

if($mybb->input['action'] == "thankyou")
{
	$output .= "postbit_rthx.gif";
}
else
{
	$output .= "postbit_thx.gif";
}

$output .= "
{$mybb->settings['thx_del']}	
</thankyou>";<br>echo $output;<br>}<br><br>function direct_action()<br>{<br>global $mybb, $lang;<br><br>if($mybb->input['action'] != "thank"  &&  $mybb->input['action'] != "remove_thank")<br>{<br>	return false;<br>}<br><br>if(file_exists($lang->path."/".$lang->language."/thx.lang.php"))	<br>{<br>	$lang->load("thx");<br>}<br>else <br>{<br>	$l = $lang->language;<br>	$lang->set_language();<br>	$lang->load("thx");<br>	$lang->set_language($l);<br>}<br>$pid=intval($mybb->input['pid']);<br><br>if($mybb->input['action'] == "thank" )<br>{<br>	do_thank($pid);<br>}<br>else if($mybb->settings['thx_del'] == "1")<br>{<br>	del_thank($pid);<br>}<br>redirect($_SERVER['HTTP_REFERER']);<br>}<br><br>function build_thank($pid, &$is_thx)<br>{<br>global $db, $mybb, $lang, $thx_cache;<br>$is_thx = 0;<br><br>$pid = intval($pid);<br><br>if(file_exists($lang->path."/".$lang->language."/thx.lang.php"))<br>{<br>	$lang->load("thx");<br>}<br>else<br>{<br>	$l=$lang->language;<br>	$lang->set_language();<br>	$lang->load("thx");<br>	$lang->set_language($l);<br>}<br>$dir = $lang->thx_dir;<br><br>$query=$db->query("SELECT th.txid, th.uid, th.adduid, th.pid, th.time, u.username, u.usergroup, u.displaygroup <br>	FROM ".TABLE_PREFIX."thx th <br>	JOIN ".TABLE_PREFIX."users u <br>	ON th.adduid=u.uid <br>	WHERE th.pid='$pid' <br>	ORDER BY th.time ASC" <br>);<br><br>while($record = $db->fetch_array($query))<br>{<br>	if($record['adduid'] == $mybb->user['uid'])<br>	{<br>		$is_thx++;<br>	}<br>	$date = my_date($mybb->settings['dateformat'].' '.$mybb->settings['timeformat'], $record['time']);<br>	if(!isset($thx_cache['showname'][$record['username']]))<br>	{<br>		$url = get_profile_link($record['adduid']);<br>		$name = format_name($record['username'], $record['usergroup'], $record['displaygroup']);<br>		$thx_cache['showname'][$record['username']] = "<a href="%5C%22%24url%5C%22" dir='\"$dir\"' rel="">$name</a>";<br>	}<br><br>	if($mybb->settings['thx_hidemode'])<br>	{<br>		$entries .= $r1comma." <span title='\"".$date."\"'>".$thx_cache['showname'][$record['username']]."</span>";<br>	}<br>	else<br>	{<br>		$entries .= $r1comma.$thx_cache['showname'][$record['username']]." <span class='\"smalltext\"'>(".$date.")</span>";<br>	}<br><br>	$r1comma = $lang->thx_comma;<br>}<br><br>return $entries;<br>}<br><br>function do_thank($pid)<br>{<br>global $db, $mybb;<br><br>$pid = intval($pid);<br><br>$check_query = $db->simple_select("thx", "count(*) as c" ,"adduid='{$mybb->user['uid']}' AND pid='$pid'", array("limit"=>"1"));<br><br>$tmp=$db->fetch_array($check_query);<br>if($tmp['c'] != 0)<br>{<br>	return false;<br>}<br><br>$check_query = $db->simple_select("posts", "uid", "pid='$pid'", array("limit"=>1));<br>if($db->num_rows($check_query) == 1)<br>{<br><br>	$tmp=$db->fetch_array($check_query);<br><br>	if($tmp['uid'] == $mybb->user['uid'])<br>	{<br>		return false;<br>	}		<br><br>	$database = array (<br>		"uid" =>$tmp['uid'],<br>		"adduid" => $mybb->user['uid'],<br>		"pid" => $pid,<br>		"time" => time()<br>	);<br><br>	unset($tmp);<br><br>	$sq = array (<br>		"UPDATE ".TABLE_PREFIX."users SET thx=thx+1 WHERE uid='{$mybb->user['uid']}' LIMIT 1",<br>		"UPDATE ".TABLE_PREFIX."users SET thxcount=thxcount+1, thxpost=CASE( SELECT COUNT(*) FROM ".TABLE_PREFIX."thx WHERE pid='{$pid}' LIMIT 1) WHEN 0 THEN thxpost+1 ELSE thxpost END WHERE uid='{$database['uid']}' LIMIT 1",<br>		"UPDATE ".TABLE_PREFIX."posts SET pthx=pthx+1 WHERE pid='{$pid}' LIMIT 1"<br>	);<br><br>	foreach($sq as $q)<br>	{<br>		$db->query($q);<br>	}<br>	$db->insert_query("thx", $database);<br>}	<br>}<br><br>function del_thank($pid)<br>{<br>global $mybb, $db;<br><br>$pid = intval($pid);<br>if($mybb->settings['thx_del'] != "1")<br>{<br>	return false;<br>}<br><br>$check_query = $db->simple_select("thx", "`uid`, `txid`" ,"adduid='{$mybb->user['uid']}' AND pid='$pid'", array("limit"=>"1"));		<br><br>if($db->num_rows($check_query))<br>{<br>	$data = $db->fetch_array($check_query);<br>	$uid = intval($data['uid']);<br>	$thxid = intval($data['txid']);<br>	unset($data);<br><br>	$sq = array (<br>		"UPDATE ".TABLE_PREFIX."users SET thx=thx-1 WHERE uid='{$mybb->user['uid']}' LIMIT 1",<br>		"UPDATE ".TABLE_PREFIX."users SET thxcount=thxcount-1, thxpost=CASE(SELECT COUNT(*) FROM ".TABLE_PREFIX."thx WHERE pid='{$pid}' LIMIT 1) WHEN 0 THEN thxpost-1 ELSE thxpost END WHERE uid='{$uid}' LIMIT 1",<br>		"UPDATE ".TABLE_PREFIX."posts SET pthx=pthx-1 WHERE pid='{$pid}' LIMIT 1"<br>	);<br><br>	$db->delete_query("thx", "txid='{$thxid}'", "1");<br><br>	foreach($sq as $q)<br>	{<br>		$db->query($q);<br>	}<br>}<br>}<br><br>function deletepost_edit($pid)<br>{<br>global $db;<br><br>$pid = intval($pid);<br>$q = $db->simple_select("thx", "uid, adduid", "pid='{$pid}'");<br><br>$postnum = $db->num_rows($q);<br>if($postnum 	{<br>	return false;<br>}<br><br>$adduids = array();<br><br>while($r = $db->fetch_array($q))<br>{<br>	$uid = intval($r['uid']);<br>	$adduids[] = $r['adduid'];<br>}<br><br>$adduids = implode(", ", $adduids);<br><br>$sq = array();<br>$sq[] = "UPDATE ".TABLE_PREFIX."users SET thxcount=thxcount-1, thxpost=thxpost-1 WHERE uid='{$uid}'";<br>$sq[] = "UPDATE ".TABLE_PREFIX."users SET thx=thx-1 WHERE uid IN ({$adduids})";<br><br>foreach($sq as $q)<br>{<br>	$db->query($q);<br>}<br><br>$db->delete_query("thx", "pid={$pid}", $postnum);<br><br>}<br><br>function thx_admin_action(&$action)<br>{<br>$action['recount_thanks'] = array ('active'=>'recount_thanks');<br>}<br><br>function thx_admin_menu(&$sub_menu)<br>{<br>$sub_menu['45'] = array	(<br>	'id'	=> 'recount_thanks',<br>	'title'	=> 'Recount thanks',<br>	'link'	=> 'index.php?module=tools/recount_thanks'<br>);<br>}<br><br>function thx_admin_permissions(&$admin_permissions)<br>{<br>$admin_permissions['recount_thanks'] = 'Can recount thanks';<br>}<br><br>function thx_admin()<br>{<br>global $mybb, $page, $db;<br>require_once MYBB_ROOT.'inc/functions_rebuild.php';<br>if($page->active_action != 'recount_thanks')<br>{<br>	return false;<br>}<br><br>if($mybb->request_method == "post")<br>{<br>	if(!isset($mybb->input['page']) || intval($mybb->input['page']) 		{<br>		$mybb->input['page'] = 1;<br>	}<br>	if(isset($mybb->input['do_recountthanks']))<br>	{<br>		if(!intval($mybb->input['thx_chunk_size']))<br>		{<br>			$mybb->input['thx_chunk_size'] = 500;<br>		}<br><br>		do_recount();<br>	}<br>	else if(isset($mybb->input['do_recountposts']))<br>	{<br>		if(!intval($mybb->input['post_chunk_size']))<br>		{<br>			$mybb->input['post_chunk_size'] = 500;<br>		}<br><br>		do_recount_post();<br>	}<br>}<br><br>$page->add_breadcrumb_item('Recount thanks', "index.php?module=tools/recount_thanks");<br>$page->output_header('Recount thanks');<br><br>$sub_tabs['thankyoulike_recount'] = array(<br>	'title'			=> 'Recount thanks',<br>	'link'			=> "index.php?module=tools/recount_thanks",<br>	'description'	=> 'Update the thanks counters'<br>);<br><br>$page->output_nav_tabs($sub_tabs, 'thankyoulike_recount');<br><br>$form = new Form("index.php?module=tools/recount_thanks", "post");<br><br>$form_container = new FormContainer('Recount thanks');<br>$form_container->output_row_header('Name');<br>$form_container->output_row_header('Chunk size', array('width' => 50));<br>$form_container->output_row_header(" ");<br><br>$form_container->output_cell("<label>Update thanks counters</label><br><div class='\"description\"'>Updates the counters for the number of thanks given/received by users and the number of thanks given to each post.</div>");<br>$form_container->output_cell($form->generate_text_box("thx_chunk_size", 100, array('style' => 'width: 150px;')));<br>$form_container->output_cell($form->generate_submit_button('Go', array("name" => "do_recountthanks")));<br>$form_container->construct_row();<br><br>$form_container->output_cell("<label>Update post counters</label><br><div class='\"description\"'>Updates the numer of posts in which a user has received thanks.</div>");<br>$form_container->output_cell($form->generate_text_box("post_chunk_size", 500, array('style' => 'width: 150px;')));<br>$form_container->output_cell($form->generate_submit_button('Go', array("name" => "do_recountposts")));<br>$form_container->construct_row();<br><br>$form_container->end();<br><br>$form->end();<br><br>$page->output_footer();<br><br>exit;<br>}<br><br>function do_recount()<br>{<br>global $db, $mybb;<br><br>$cur_page = intval($mybb->input['page']);<br>$per_page = intval($mybb->input['thx_chunk_size']);<br>$start = ($cur_page-1) * $per_page;<br>$end = $start + $per_page;<br><br>if ($cur_page == 1)<br>{<br>	$db->write_query("UPDATE ".TABLE_PREFIX."users SET thx='0', thxcount='0'");<br>	$db->write_query("UPDATE ".TABLE_PREFIX."posts SET pthx='0'");<br>}<br><br>$query = $db->simple_select("thx", "COUNT(txid) AS thx_count");<br>$thx_count = $db->fetch_field($query, 'thx_count');<br><br>$query = $db->query("<br>	SELECT uid, adduid, pid <br>	FROM ".TABLE_PREFIX."thx <br>	ORDER BY time ASC <br>	LIMIT $start, $per_page <br>");<br><br>$post_thx = array();<br>$user_thx = array();<br>$user_thx_to = array();<br><br>while($thx = $db->fetch_array($query))<br>{<br>	if($post_thx[$thx['pid']])<br>	{<br>		$post_thx[$thx['pid']]++;<br>	}<br>	else<br>	{<br>		$post_thx[$thx['pid']] = 1;<br>	}<br>	if($user_thx[$thx['adduid']])<br>	{<br>		$user_thx[$thx['adduid']]++;<br>	}<br>	else<br>	{<br>		$user_thx[$thx['adduid']] = 1;<br>	}<br>	if($user_thx_to[$thx['uid']])<br>	{<br>		$user_thx_to[$thx['uid']]++;<br>	}<br>	else<br>	{<br>		$user_thx_to[$thx['uid']] = 1;<br>	}<br>}<br><br>if(is_array($post_thx))<br>{<br>	foreach($post_thx as $pid => $change)<br>	{<br>		$db->write_query("UPDATE ".TABLE_PREFIX."posts SET pthx=pthx+$change WHERE pid='$pid'");<br>	}<br>}<br>if(is_array($user_thx))<br>{<br>	foreach($user_thx as $adduid => $change)<br>	{<br>		$db->write_query("UPDATE ".TABLE_PREFIX."users SET thx=thx+$change WHERE uid='$adduid'");<br>	}<br>}<br>if(is_array($user_thx_to))<br>{<br>	foreach($user_thx_to as $uid => $change)<br>	{<br>		$db->write_query("UPDATE ".TABLE_PREFIX."users SET thxcount=thxcount+$change WHERE uid='$uid'");<br>	}<br>}<br>my_check_proceed($thx_count, $end, $cur_page+1, $per_page, "thx_chunk_size", "do_recountthanks", "Successfully updated the thanks counters");<br>}<br><br>function do_recount_post()<br>{<br>global $db, $mybb;<br><br>$cur_page = intval($mybb->input['page']);<br>$per_page = intval($mybb->input['post_chunk_size']);<br>$start = ($cur_page-1) * $per_page;<br>$end = $start + $per_page;<br><br>if ($cur_page == 1)<br>{<br>	$db->write_query("UPDATE ".TABLE_PREFIX."users SET thxpost='0'");<br>}<br><br>$query = $db->simple_select("thx", "COUNT(distinct pid) AS post_count");<br>$post_count = $db->fetch_field($query, 'post_count');<br><br>$query = $db->query("<br>	SELECT uid, pid <br>	FROM ".TABLE_PREFIX."thx <br>	GROUP BY pid <br>	ORDER BY pid ASC <br>	LIMIT $start, $per_page <br>");<br><br>while($thx = $db->fetch_array($query))<br>{<br>	$db->write_query("UPDATE ".TABLE_PREFIX."users SET thxpost=thxpost+1 WHERE uid='{$thx['uid']}'");<br>}<br><br>my_check_proceed($post_count, $end, $cur_page+1, $per_page, "post_chunk_size", "do_recountposts", "Successfully updated the post counters");<br>}<br><br>function my_check_proceed($current, $finish, $next_page, $per_page, $name_chunk, $name_submit, $message)<br>{<br>global $page;<br><br>if($finish >= $current)<br>{<br>	flash_message($message, 'success');<br>	admin_redirect("index.php?module=tools/recount_thanks");<br>}<br>else<br>{<br>	$page->output_header();<br><br>	$form = new Form("index.php?module=tools/recount_thanks", 'post');<br><br>	echo $form->generate_hidden_field("page", $next_page);<br>	echo $form->generate_hidden_field($name_chunk, $per_page);<br>	echo $form->generate_hidden_field($name_submit, "Go");<br>	echo "<div class='\"confirm_action\"'>\n";
	echo "
Click \"Proceed\" to continue the recount and rebuild process.\n";
	echo "
\n";
	echo "
\n";
	echo $form->generate_submit_button("Proceed", array('class' => 'button_yes'));
	echo "\n";
	echo "</div>\n";<br><br>	$form->end();<br><br>	$page->output_footer();<br>	exit;<br>}<br>}<br><br>?&g

Muudetud liikme QzeT'i poolt

b

Jaga seda postitust


Postituse link
Share on other sites
  • 0
SUPERVIP

Muuta milleks? Mida? Eestikeelseks? Thanks nupule tumedat tausta?

Jaga seda postitust


Postituse link
Share on other sites
  • 0
thanx nupule seda tumedat tausta jah see tumeda tausta class nimetus on "buttonn" aga ma ei leia mitte kuskilt kus seda editida . kõik templateda läbi tuhlanud mybbs

 

Päris kindel, et mybb templates polegi nuppe. Need peaksid kõib pildid olema ja sa pead ise valmis tegema.

Osad templated annavad PSD kaasa, et saaksid uue nupu valmis teha, kui ei anna siis otsi taoline font ja tee ise valmis.


b_560_95_1.png

Jaga seda postitust


Postituse link
Share on other sites
Külaline
This topic is now closed to further replies.

×
×
  • Loo uus...

Oluline informatsioon

Selle veebisaidi paremaks muutmiseks oleme teie seadmesse paigutanud küpsised . Võite kohandada oma küpsiste seadeid , vastasel juhul eeldame, et te olete küpsiste kasutamisega nõus kui jätkate veebisaidil sirvimist.. Palun lugege läbi Kasutustingimused ja Privaatsuspoliitika.