Skip to content

Commit

Permalink
v1.6a
Browse files Browse the repository at this point in the history
  • Loading branch information
FredBardin committed Oct 7, 2017
1 parent 7c2fe6b commit 0bf400f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# ![phpMyHue](img/phpmyhue.png)

Php web interface to manage Philips Hue lights in a local network.
Php web interface and api to manage Philips Hue lights in a local network.

## Main Functionnalities
* **Full group management**
* **Scenes update or creation**
* Manage and run **scripted effects** (debug mode available) ([see wiki](https://github.com/FredBardin/phpMyHue/wiki/Effects-scripts))
* Manage and run xml **scripted effects** (debug mode available) ([see wiki](https://github.com/FredBardin/phpMyHue/wiki/Effects-scripts))
* **Full rules management** for sensors (simplified mode available for **Hue Tap** switch with on/off functionalities)
* Set color and/or brightness for a light or several at once
* Copy color settings between lights (copy to, copy from, switch with)
Expand Down
2 changes: 2 additions & 0 deletions histo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ v1.6 - /09/2017 :
- Don't display 'LightSource' groups (already included into 'Luminaire' groups)
WIP - Display now color and brightness of a lamp in details tab even if turned off
WIP - Lights details tab now always displays changes immediately for color or brightness
- Add choose language function in 'about' tab for updatable config file
(depend on your installation)
v1.5 - 11/09/2016 :
- Add Sensors Rules management
- Update color conversion with new formulas from meethue
Expand Down
18 changes: 13 additions & 5 deletions include/about.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<?php
//----------------------------------------------
// About pannel
// F. Bardin 12/04/2015
//-----------------------------------
//----------------------------------------------
// 30/09/2017 : add language update capability
//----------------------------------------------
// Anti-hack
if (! defined('ANTI_HACK')){exit;}

include 'include/functions.php';
?>
<SCRIPT language="javascript">
$('#detail').hide("slide");
</SCRIPT>
<DIV ID=about>phpMyHue 1.6<BR>
&copy; <A HREF="mailto:[email protected]" CLASS=about>F. Bardin</A> 12-2016/01-2017<BR>
&copy; <A HREF="mailto:[email protected]" CLASS=about>F. Bardin</A> 04-2015/09-2017<BR>
<small>
Bridge IP : <?php echo $bridgeip?><BR>
Current language : <?php echo $lang?>
<SPAN CLASS=aligntxt>Current language : </SPAN><?php choose_lang() ?>
<BR><DIV ID=histo>
<H3><?php echo $trs['Histo']?></H3>
<SPAN><?php echo $trs['Histo']?></SPAN>
<DIV>
<?php
$histo = @file("histo.txt");
Expand All @@ -26,7 +30,11 @@
?>
</DIV></DIV>
</small></DIV>
<SCRIPT>
<SCRIPT language="javascript">
$("#c_lang").selectmenu({width : 'auto'});
$("#c_lang").on("selectmenuchange", function(){
location.assign('index.php?updconf=y&lang='+$(this).val());
});
$('#histo').accordion({
collapsible: true,
heightStyle: "content",
Expand Down
3 changes: 1 addition & 2 deletions include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
These functions are used by several screens or need an external call by ajax
---------------------------------------------------
huecolor.php : includes functions to manage colors
choose_lang : allow to choose a lang amon exiting translation files
choose_lang : allow to choose a lang among exiting translation files
display_bri_slider : display a slider to manage brightness
display_td_checkbox : display selection checkbox on a row
display_light_row : display a light row
Expand Down Expand Up @@ -264,5 +264,4 @@ function selMethod($selmethid,$methval){

echo "<SCRIPT>\$(\"#$selmethid\").selectmenu({width : 'auto'});</SCRIPT>\n";
} // selMethod

?>
70 changes: 58 additions & 12 deletions include/init_conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,37 @@
$conf_file = "config.php";
$template_file = "config.tpl.php";


ini_set('default_socket_timeout', 1);

// If config file does not exist : copy template
if (file_exists("include/$conf_file")){
@$updconf = $_REQUEST['updconf'];
if (isset($updconf)){
// Backup config parameters sent
@$bridgeip_bck = $_REQUEST['bridgeip'];
@$username_bck = $_REQUEST['username'];
@$lang_bck = $_REQUEST['lang'];

// Load config to initialize all parameters
include "include/$conf_file";

// Update old config with new parameter
if (isset($bridgeip_bck)){$bridgeip = $bridgeip_bck;}
if (isset($username_bck)){$username = $username_bck;}
if (isset($lang_bck)){$lang = $lang_bck;}

// Write new config
// TODO ==> TO TRANSLATE AND TO DISPLAY as message
if (writeConf()){$msg="Config updated";}
else {echo "Problem writing config file";}
}

// Read config
include "include/$conf_file";
} else {
// Init parameters
@$confstep = $_REQUEST['confstep'];

// Load config parameters
@$bridgeip = $_REQUEST['bridgeip'];
@$username = $_REQUEST['username'];
@$lang = $_REQUEST['lang'];
Expand Down Expand Up @@ -143,7 +164,35 @@ function getUserName(){
// Function to record configuration
//----------------------------------------------
function recordConf(){
global $trs,$bridgeip,$username,$lang,$conf_file,$template_file;
global $trs,$conf_file,$template_file;

$conf_html="Y";
if (! writeConf($conf_html)){// Warning, conf_html is used as reference in the called function. Don't use litteral value.
echo "<BR><B>".$trs["Fatal_Error"]."</B> : ".$trs["Automatic_creation_of"]." 'include/$conf_file' ".$trs["failed"].".<BR>";
echo "<U>".$trs["Copy_manually"]." 'include/$template_file' ".$trs["to"]." 'include/$conf_file' ".$trs["then_fill_this_file_with_the_following_values"]."</U> :<BR>";
} else {
echo "<B>".$trs["Configuration_file_created_successfully_with_the_following_values"]." :</B><BR>";
}
// Echo to screen
echo "<BR><DIV STYLE=\"margin:auto;width:500px;border:1px outset #000000;text-align:left;\"><CODE>".$conf_html."</CODE></DIV>";

} // recordConf

//----------------------------------------------
// Function to update configuration
// (no part of ini process)
//----------------------------------------------
function updateConf(){
} // updateConf

//-----------------------------------------------------------------------------------------------
// Function to (re)write completly config.php file
// Parameter : conf_html (optional). If set get in return the config file content in html format
// Return : true/false (true=writing ok, false=error)
// All config parameters must be already set as global
//-----------------------------------------------------------------------------------------------
function writeConf(&$conf_html=""){
global $trs,$bridgeip,$username,$lang,$conf_file;

// Init config content
$conf_array = array(
Expand All @@ -157,6 +206,8 @@ function recordConf(){
"\$lang = \"$lang\";",
"?>"
);

// Format array content to be usable
$conf_count = count($conf_array);
$conf_rec = "";
$conf_html = "";
Expand All @@ -165,14 +216,9 @@ function recordConf(){
$conf_html .= str_replace(" ","&nbsp;",htmlentities($conf_array[$i]))."<BR>\n";
}

if (! file_put_contents("include/$conf_file",$conf_rec)){
echo "<BR><B>".$trs["Fatal_Error"]."</B> : ".$trs["Automatic_creation_of"]." 'include/$conf_file' ".$trs["failed"].".<BR>";
echo "<U>i".$trs["Copy_manually"]." 'include/$template_file' ".$trs["to"]." 'include/$conf_file' ".$trs["then_fill_this_file_with_the_following_values"]."</U> :<BR>";
} else {
echo "<B>".$trs["Configuration_file_created_successfully_with_the_following_values"]." :</B><BR>";
}
// Echo to screen
echo "<BR><DIV STYLE=\"margin:auto;width:250px;border:1px outset #000000;text-align:left;\"><CODE>".$conf_html."</CODE></DIV>";
// Write conf file
if (file_put_contents("include/$conf_file",$conf_rec)){return true;}
else {return false;}
} // writeConf

} // recordConf
?>

0 comments on commit 0bf400f

Please sign in to comment.