MyBB Requests
[Plugin] Userbar Hue Changer
Submitted by Tropical, 19-05-2015, 02:10 AM, Thread ID: 3953
Thread Closed
RE: [Plugin] Userbar Hue Changer
20-05-2015, 09:26 AM
#30 20-05-2015, 04:57 AMTropical Wrote:19-05-2015, 12:50 PMAndresXZ09 Wrote:Code:<?php
function modulateImage($imagePath, $hue, $brightness, $saturation) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->modulateImage($saturation, $hue);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
?>
Pretty much that's an example of the modulateImage
I have technically just made this plugin....
I am wondering where to put that piece of code?? :noh:
The places where I dunno whatto put there;; I just wrote "[ERMM... idk?]
This is my code:
PHP Code:<?php
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
die("Direct initialization of this file is not allowed.");
// add hooks
$plugins->add_hook('usercp_start', 'userbarhuechanger_page');
function userbarhuechanger_info()
{
return array(
"name" => "Userbar Hue Changer",
"description" => "Allows hue rotation of userbars",
"website" => "NULL",
"author" => "CallingChain",
"authorsite" => "http://gamingtalks.com/index.php",
"version" => "1.0",
"codename" => "",
"compatibility" => "18*"
);
}
function userbrhuechanger_install()
{
global $db, $lang;
// create settings group
$insertarray = array(
'name' => 'userbarhuechanger',
'title' => 'Userbar Hue Changer',
'description' => "Settings for Userbar Hue Changer",
'disporder' => 100,
'isdefault' => 0
);
$gid = $db->insert_query("settinggroups", $insertarray);
// add settings
$setting = array(
"sid"=> NULL,
"name"=> "userbarhuechanger_usergroups",
"title"=> "Allowed Usergroups",
"description"=> "Enter the IDs of the groups allowed to use this feature. (use \'all\' to allow everyone)",
"optionscode"=> "text",
"value"=> 'all',
"disporder"=> 1,
"gid"=> $gid
);
$db->insert_query("settings", $setting);
rebuild_settings();
// insert templates
$template = array(
"tid" => "NULL",
"title" => "userbarhuechanger",
"template" => $db->escape_string('
<html>
<head>
<title>{$mybb->settings[\'bbname\']} - {$lang->userstyle_change_style}</title>
{$headerinclude}
</head>
<body>
{$header}
<table width="100%" border="0" align="center">
<tr>
{$usercpnav}
<td valign="top">
{$errors}
<form action="usercp.php?action=format" method="post">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->userbarhuechanger_change_hue}</strong></td>
</tr>
<tr>
<td class="tcat" colspan="2"><strong>{$lang->userbarhuechanger_change_hue_desc}</strong></td>
</tr>
</table>
<br />
<div align="center">
<input type="hidden" name="action" value="userbarhuechanger" />
<input type="submit" class="button" name="submit" value="{$lang->userbarhuechanger_submit}" />
</div>
</form>
<br />
<br />
</td>
</tr>
</table>
{$footer}
</body>
</html>
'),
"sid" => "-1",
);
$db->insert_query("templates", $template);
}
function userbarhuechanger_is_installed()
{
global $db;
if ($db->table_exists('userbarhuechanger'))
return true;
return false;
}
function userbarhuechanger_uninstall()
{
global $db, $mybb;
/* drop table */
if ($db->table_exists('userbarhuechanger'))
$db->drop_table('userbarhuechanger');
// delete settings group
$db->delete_query("settinggroups", "name = 'userbarhuechanger'");
// remove settings
$db->delete_query('settings', 'name IN (\'userbarhuechanger_usergroups\')');
rebuild_settings();
// delete templates
$db->delete_query('templates', 'title IN ( \'userbarhuechanger\')');
}
function userbarhuechanger_activate()
{
global $db, $cache;
$userbarhuechanger = array();
// rebuild our userbarhuechanger cache
$query = $db->query("
SELECT u.username, a.*
FROM ".TABLE_PREFIX."userbarhuechanger a
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
");
while($user = $db->fetch_array($query))
{
$userbarhuechanger[$user['username']] = array('colour' => $user['colour'], 'shadow' => $user['shadow']);
}
$cache->update('userbarhuechanger', $userbarhuechanger);
}
function userbarhuechanger_deactivate()
{
global $db;
$db->delete_query('datacache', 'title=\'userbarhuechanger\'');
}
function userbarhuechanger_check_permissions($groups_comma)
{
global $mybb;
if ($groups_comma == '')
return false;
if ($groups_comma == 'all')
return true;
$groups = explode(",", $groups_comma);
$ourgroups = explode(",", $mybb->user['additionalgroups']);
$ourgroups[] = $mybb->user['usergroup'];
if(count(array_intersect($ourgroups, $groups)) == 0)
return false;
else
return true;
}
function userstyle_page()
{
global $mybb, $lang, $cache, $db, $templates, $header, $headerinclude, $footer, $theme, $usercpnav;
$lang->load("userbarhuechanger");
if($mybb->input['action'] != 'userbarhuechanger')
return;
if (!$mybb->user['uid'])
error_no_permission();
if (!userbarhuechanger_check_permissions($mybb->settings['userbarhuechanger_usergroups']))
error_no_permission();
if($mybb->request_method == "post")
{
// Verify incoming POST request
verify_post_check($mybb->input['my_post_key']);
[ERMM.... idk?]
// Update database table
$db->replace_query('userbarhuechanger', array('uid' => (int)$mybb->user['uid'], [ERRMM... idk?]
// Rebuild cache
$userbarhuechanger = array();
$query = $db->query("
SELECT u.username, a.*
FROM ".TABLE_PREFIX."userbarhuechanger a
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
");
while($user = $db->fetch_array($query))
{
$userbarhuechanger[$user['username']] = array('colour' => $user['colour'], 'shadow' => $user['shadow']);
}
$cache->update('userbarhuechanger', $userbarhuechanger);
redirect("usercp.php", $lang->userbarhuechanger_success_message);
}
}
PHP Code:
$userbarhuechanger[$user['username']] = array('colour' => $user['colour'], 'shadow' => $user['shadow']);
seems legit...
Users browsing this thread: 3 Guest(s)