Skip to content
Permalink
Browse files

Reorganize new theme functions

  • Loading branch information...
NEMS Linux
NEMS Linux committed Mar 3, 2019
1 parent 0a2943e commit b752bdf43c86e2b4f23720da970fc4e4c9f6d302
Showing with 87 additions and 156 deletions.
  1. +2 −96 config/index.php
  2. +7 −0 css/custom.css
  3. +1 −37 inc/bgcolor.php
  4. +75 −0 inc/functions.php
  5. +2 −23 inc/wallpaper.php
@@ -22,6 +22,7 @@
#
###########################################################################
*/
error_reporting(E_ALL ^ E_NOTICE);
include('/var/www/html/inc/functions.php');
if (!initialized()) {
@@ -47,58 +48,6 @@
$v++;
}
if (!function_exists(hex2rgb)) {
function hex2rgb($color){
$color = str_replace('#', '', $color);
if (strlen($color) != 6){ return array(0,0,0); }
$rgb = array();
for ($x=0;$x<3;$x++){
$rgb[$x] = hexdec(substr($color,(2*$x),2));
}
return $rgb;
}
}
function rgb2hsv($rgb){
$r = $rgb[0] / 255;
$g = $rgb[1] / 255;
$b = $rgb[2] / 255;
$v = max($r, $g, $b);
$diff = $v - min($r, $g, $b);
$diffc = function($c) use ($v, $diff) {
return ($v - $c) / 6 / $diff + 1 / 2;
};
if($diff == 0){
$h = $s = 0;
}else{
$s = $diff / $v;
$rr = $diffc($r);
$gg = $diffc($g);
$bb = $diffc($b);
if($r === $v){
$h = $bb - $gg;
}else if($g === $v){
$h = (1 / 3) + $rr - $bb;
}else if($b === $v){
$h = (2 / 3) + $gg - $rr;
}
if($h < 0){
$h += 1;
}else if($h > 1){
$h -= 1;
}
}
$hsv = round($h * 360) . ',' . round($s * 100) . '%,' . round($v * 100) . '%';
return $hsv;
}
// Nagios config
if (ver('nems') < 1.4) {
# LEGACY VERSION
@@ -112,7 +61,7 @@ function rgb2hsv($rgb){
if (isset($_POST) && isset($_POST['email'])) {
if (isset($_FILES)) {
if (isset($_FILES) && strlen($_FILES['file']['tmp_name']) > 0) {
$verifyimg = getimagesize($_FILES['file']['tmp_name']);
if ( // only allow png and jpg
@@ -820,47 +769,4 @@ function sanitize($string) {
</div>
<?php
include('/var/www/html/inc/footer.php');
// https://stackoverflow.com/questions/1773698/rgb-to-hsv-in-php
function RGB_TO_HSV ($R, $G, $B) // RGB Values:Number 0-255
{ // HSV Results:Number 0-1
$HSL = array();
$var_R = ($R / 255);
$var_G = ($G / 255);
$var_B = ($B / 255);
$var_Min = min($var_R, $var_G, $var_B);
$var_Max = max($var_R, $var_G, $var_B);
$del_Max = $var_Max - $var_Min;
$V = $var_Max;
if ($del_Max == 0)
{
$H = 0;
$S = 0;
}
else
{
$S = $del_Max / $var_Max;
$del_R = ( ( ( $var_Max - $var_R ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
$del_G = ( ( ( $var_Max - $var_G ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
$del_B = ( ( ( $var_Max - $var_B ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
if ($var_R == $var_Max) $H = $del_B - $del_G;
else if ($var_G == $var_Max) $H = ( 1 / 3 ) + $del_R - $del_B;
else if ($var_B == $var_Max) $H = ( 2 / 3 ) + $del_G - $del_R;
if ($H<0) $H++;
if ($H>1) $H--;
}
$HSL['H'] = $H;
$HSL['S'] = $S;
$HSL['V'] = $V;
return $HSL;
}
?>
@@ -111,3 +111,10 @@ li, li a, .one-page-header .navbar-nav a.dropdown-toggle, li.dropdown, a.dropdow
.promo-text:after {
background: transparent !important;
}

.parallax-counter-v4 {
background: rgba(0,0,0,1) !important;
}
.parallax-counter-v4:after {
background: rgba(0,0,0,1) !important;
}
@@ -1,30 +1,7 @@
<?php
$defaultbgcolor = '040111';
if (!function_exists('hsv2rgb')) {
function hsv2rgb($hue,$sat,$val) {;
$rgb = array(0,0,0);
//calc rgb for 100% SV, go +1 for BR-range
for($i=0;$i<4;$i++) {
if (abs($hue - $i*120)<120) {
$distance = max(60,abs($hue - $i*120));
$rgb[$i % 3] = 1 - (($distance-60) / 60);
}
}
//desaturate by increasing lower levels
$max = max($rgb);
$factor = 255 * ($val/100);
for($i=0;$i<3;$i++) {
//use distance between 0 and max (1) and multiply with value
$rgb[$i] = round(($rgb[$i] + ($max - $rgb[$i]) * (1 - $sat/100)) * $factor);
}
$rgb['html'] = sprintf('%02X%02X%02X', $rgb[0], $rgb[1], $rgb[2]);
return $rgb;
}
}
include_once('/var/www/html/inc/functions.php');
$conftmp = file('/usr/local/share/nems/nems.conf');
if (is_array($conftmp) && count($conftmp) > 0) {
@@ -74,19 +51,6 @@ function hsv2rgb($hue,$sat,$val) {;
}
}
if (!function_exists(hex2rgb)) {
function hex2rgb($color){
$color = str_replace('#', '', $color);
if (strlen($color) != 6){ return array(0,0,0); }
$rgb = array();
for ($x=0;$x<3;$x++){
$rgb[$x] = hexdec(substr($color,(2*$x),2));
}
return $rgb;
}
}
$bgcolorRGB = hex2rgb($bgcolor);
?>
@@ -209,4 +209,79 @@ function initialized() {
return false;
}
}
// Theme color helpers
function hex2rgb($color){
$color = str_replace('#', '', $color);
if (strlen($color) != 6){ return array(0,0,0); }
$rgb = array();
for ($x=0;$x<3;$x++){
$rgb[$x] = hexdec(substr($color,(2*$x),2));
}
return $rgb;
}
function rgb2hsv($rgb){
$r = $rgb[0] / 255;
$g = $rgb[1] / 255;
$b = $rgb[2] / 255;
$v = max($r, $g, $b);
$diff = $v - min($r, $g, $b);
$diffc = function($c) use ($v, $diff) {
return ($v - $c) / 6 / $diff + 1 / 2;
};
if($diff == 0){
$h = $s = 0;
}else{
$s = $diff / $v;
$rr = $diffc($r);
$gg = $diffc($g);
$bb = $diffc($b);
if($r === $v){
$h = $bb - $gg;
}else if($g === $v){
$h = (1 / 3) + $rr - $bb;
}else if($b === $v){
$h = (2 / 3) + $gg - $rr;
}
if($h < 0){
$h += 1;
}else if($h > 1){
$h -= 1;
}
}
$hsv = round($h * 360) . ',' . round($s * 100) . '%,' . round($v * 100) . '%';
return $hsv;
}
function hsv2rgb($hue,$sat,$val) {;
$rgb = array(0,0,0);
//calc rgb for 100% SV, go +1 for BR-range
for($i=0;$i<4;$i++) {
if (abs($hue - $i*120)<120) {
$distance = max(60,abs($hue - $i*120));
$rgb[$i % 3] = 1 - (($distance-60) / 60);
}
}
//desaturate by increasing lower levels
$max = max($rgb);
$factor = 255 * (intval($val)/100);
for($i=0;$i<3;$i++) {
//use distance between 0 and max (1) and multiply with value
$rgb[$i] = round(($rgb[$i] + ($max - $rgb[$i]) * (1 - intval($sat)/100)) * $factor);
}
$rgb['html'] = sprintf('%02X%02X%02X', $rgb[0], $rgb[1], $rgb[2]);
return $rgb;
}
?>
@@ -5,6 +5,7 @@
7 = color picker
8 = user uploaded
*/
include_once('/var/www/html/inc/functions.php');
$nemsver = shell_exec('/usr/local/bin/nems-info nemsver');
@@ -66,7 +67,7 @@
$s = trim($tmp[1]);
$v = trim($tmp[2]);
$rgb=hsv2rgb($h,$s,$v);
$vDark = ($v-40);
$vDark = (intval($v)-40);
if ($vDark < 1) $vDark = 1;
$rgbDark=hsv2rgb($h,$s,$vDark);
$output = "
@@ -203,26 +204,4 @@
</style>";
}
if (!function_exists('hsv2rgb')) {
function hsv2rgb($hue,$sat,$val) {;
$rgb = array(0,0,0);
//calc rgb for 100% SV, go +1 for BR-range
for($i=0;$i<4;$i++) {
if (abs($hue - $i*120)<120) {
$distance = max(60,abs($hue - $i*120));
$rgb[$i % 3] = 1 - (($distance-60) / 60);
}
}
//desaturate by increasing lower levels
$max = max($rgb);
$factor = 255 * ($val/100);
for($i=0;$i<3;$i++) {
//use distance between 0 and max (1) and multiply with value
$rgb[$i] = round(($rgb[$i] + ($max - $rgb[$i]) * (1 - $sat/100)) * $factor);
}
$rgb['html'] = sprintf('#%02X%02X%02X', $rgb[0], $rgb[1], $rgb[2]);
return $rgb;
}
}
?>

0 comments on commit b752bdf

Please sign in to comment.
You can’t perform that action at this time.