Alright unhappyelf inspired me to get this working using HFM. I know there are a lot of people that use HFM so I figured this would be a good how to for anyone wanting a live folding sig that use HFM.net...
So I re wrote the code to get this to work with HFM.net and it works great.
What you need:
1) Your image you will be using for the sig... Here is a template based on the position in the below code. You can use this as a starting base...
2) A PHP content file but named with a png extension. To do this just open notepad, then past the below code into notepad...Don't forget when you save it choose all files and name it something.png
<?php
$results = simpleXMLToArray(simplexml_load_file("Overview.xml"));
$oldppd=0;
$k=0;
$onoff=0;
for($i=0 ;$i<=9;$i++){
$newppd = $results['Instance'][$i]['ppd'];
if($newppd > $oldppd){
$oldppd=$newppd;
$k=$i;
}
}
if($k == 0){
for($i=0 ;$i<=9;$i++){
if($results['Instance'][$i]['points'] > 0){
$k=$i;
}
}
}
$image = "FoldingSig.png";
$im = imagecreatefrompng($image);
$wc = ImageColorAllocate ($im, 255, 255, 255);
$green = ImageColorAllocate ($im, 0, 255, 0);
$red = ImageColorAllocate ($im, 223, 56, 5);
$yellow = ImageColorAllocate ($im, 255, 255, 0);
$k=1;
if($results['Instance'][$k]['Status'] == "Running"){ImageString($im, 35, 50, 48, "Running", $green);}
if($results['Instance'][$k]['Status'] == "Paused"){ImageString($im, 35, 50, 48, "Paused", $yellow);}
if($results['Instance'][$k]['Status'] == "Stopped"){ImageString($im, 35, 50, 48, "Stopped", $red);}
if($results['Instance'][$k]['Status'] == "Disabled"){ImageString($im, 35, 50, 48, "Disabled", $wc);}
ImageString($im, 40, 0, 48, $results['Instance'][$k]['Name'], $wc);
ImageString($im, 4, 125, 48, $results['Instance'][$k]['ProjectRunCloneGen'], $wc);
ImageString($im, 4, 310, 48, $results['Instance'][$k]['Credit'], $wc);
ImageString($im, 4, 365, 48, $results['Instance'][$k]['PercentComplete'], $wc);
ImageString($im, 4, 395, 48, $results['Instance'][$k]['PPD'], $wc);
ImageString($im, 4, 475, 48, $results['Instance'][$k]['TPF'], $wc);
$k=2;
if($results['Instance'][$k]['Status'] == "Running"){ImageString($im, 35, 50, 60, "Running", $green);}
if($results['Instance'][$k]['Status'] == "Paused"){ImageString($im, 35, 50, 60, "Paused", $yellow);}
if($results['Instance'][$k]['Status'] == "Stopped"){ImageString($im, 35, 50, 60, "Stopped", $red);}
if($results['Instance'][$k]['Status'] == "Disabled"){ImageString($im, 35, 50, 60, "Disabled", $wc);}
ImageString($im, 40, 0, 60, $results['Instance'][$k]['Name'], $wc);
ImageString($im, 4, 125, 60, $results['Instance'][$k]['ProjectRunCloneGen'], $wc);
ImageString($im, 4, 310, 60, $results['Instance'][$k]['Credit'], $wc);
ImageString($im, 4, 365, 60, $results['Instance'][$k]['PercentComplete'], $wc);
ImageString($im, 4, 395, 60, $results['Instance'][$k]['PPD'], $wc);
ImageString($im, 4, 475, 60, $results['Instance'][$k]['TPF'], $wc);
$k=0;
if($results['Instance'][$k]['Status'] == "Running"){ImageString($im, 35, 50, 72, "Running", $green);}
if($results['Instance'][$k]['Status'] == "Paused"){ImageString($im, 35, 50, 72, "Paused", $yellow);}
if($results['Instance'][$k]['Status'] == "Stopped"){ImageString($im, 35, 50, 72, "Stopped", $red);}
if($results['Instance'][$k]['Status'] == "Disabled"){ImageString($im, 35, 50, 72, "Disabled", $wc);}
ImageString($im, 40, 0, 72, $results['Instance'][$k]['Name'], $wc);
ImageString($im, 4, 125, 72, $results['Instance'][$k]['ProjectRunCloneGen'], $wc);
ImageString($im, 4, 310, 72, $results['Instance'][$k]['Credit'], $wc);
ImageString($im, 4, 365, 72, $results['Instance'][$k]['PercentComplete'], $wc);
ImageString($im, 4, 395, 72, $results['Instance'][$k]['PPD'], $wc);
ImageString($im, 4, 475, 72, $results['Instance'][$k]['TPF'], $wc);
header("Content-Type: image/png");
Imagepng($im);
ImageDestroy ($im);
function simpleXMLToArray($xml,
$flattenValues=true,
$flattenAttributes = true,
$flattenChildren=true,
$valueKey='@value',
$attributesKey='@attributes',
$childrenKey='@children'){
$return = array();
if(!($xml instanceof SimpleXMLElement)){return $return;}
$name = $xml->getName();
$_value = trim((string)$xml);
if(strlen($_value)==0){$_value = null;};
if($_value!==null){
if(!$flattenValues){$return[$valueKey] = $_value;}
else{$return = $_value;}
}
$children = array();
$first = true;
foreach($xml->children() as $elementName => $child){
$value = simpleXMLToArray($child, $flattenValues, $flattenAttributes, $flattenChildren, $valueKey, $attributesKey, $childrenKey);
if(isset($children[$elementName])){
if($first){
$temp = $children[$elementName];
unset($children[$elementName]);
$children[$elementName][] = $temp;
$first=false;
}
$children[$elementName][] = $value;
}
else{
$children[$elementName] = $value;
}
}
if(count($children)>0){
if(!$flattenChildren){$return[$childrenKey] = $children;}
else{$return = array_merge($return,$children);}
}
$attributes = array();
foreach($xml->attributes() as $name=>$value){
$attributes[$name] = trim($value);
}
if(count($attributes)>0){
if(!$flattenAttributes){$return[$attributesKey] = $attributes;}
else{$return = array_merge($return, $attributes);}
}
return $return;
}
?>
HFM.Net Export XML Next Step is to setup HFM.net to send the xml file to ftp location or local location depending how you are hosting and where your clients are running.
To do open HFM.net and click on Edit/Preferences. Then click the Create a Web Site checkbox and browse to your path you want the xml file stored. After that check the checkbox for Copy XML to target. And thats all you have to do.
Hosting using IIS In IIS in the
Actions pane, click
Add Module Mapping.... In the
Add Module Mapping dialog box, specify the configuration settings as follows:
Request path: *.pngModule: FastCgiModuleExecutable: "C:\[Path to your PHP installation]\php-cgi.exe"Name: PNG as PHP
And thats all thats needed for IIS to open a PHP file as a PNG...
If you have any questions or would like some assistance with IIS send me a pm. I would be glad to help.
post edited by Bowenac - 2011/01/23 12:14:32