How-To: Live Folding Sig using HFM.

Author
Bowenac
CLASSIFIED ULTRA Member
  • Total Posts : 5642
  • Reward points : 0
  • Joined: 2007/10/25 23:40:18
  • Location: Puget Sound WA State
  • Status: offline
  • Ribbons : 17
2011/01/22 20:52:51 (permalink)
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: *.png
  • Module: FastCgiModule
  • Executable: "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
  • #1

    28 Replies Related Threads

      clifford_cooley
      ACX Member
      • Total Posts : 469
      • Reward points : 0
      • Joined: 2010/11/03 18:40:27
      • Location: Arkansas, USA
      • Status: offline
      • Ribbons : 0
      Re:How-To: Live Folding Sig using HFM. 2011/01/22 20:59:25 (permalink)
      Nice!!!
       
      HFM.Net will allow for Multi-PC configs, where Tracker V2 is only one PC.
      #2
      Bowenac
      CLASSIFIED ULTRA Member
      • Total Posts : 5642
      • Reward points : 0
      • Joined: 2007/10/25 23:40:18
      • Location: Puget Sound WA State
      • Status: offline
      • Ribbons : 17
      Re:How-To: Live Folding Sig using HFM. 2011/01/22 20:59:51 (permalink)
      clifford_cooley

      Nice!!!

      HFM.Net will allow for Multi-PC configs, where Tracker V2 is only one PC.

      Yup!!
      #3
      metal_god69
      FTW Member
      • Total Posts : 1602
      • Reward points : 0
      • Joined: 2008/04/22 23:48:01
      • Location: Regina, Canada
      • Status: offline
      • Ribbons : 2
      Re:How-To: Live Folding Sig using HFM. 2011/01/22 22:19:51 (permalink)
      Thanks Adam

                                   
        
      #4
      Bowenac
      CLASSIFIED ULTRA Member
      • Total Posts : 5642
      • Reward points : 0
      • Joined: 2007/10/25 23:40:18
      • Location: Puget Sound WA State
      • Status: offline
      • Ribbons : 17
      Re:How-To: Live Folding Sig using HFM. 2011/01/22 23:39:58 (permalink)
      metal_god69

      Thanks Adam

      No problem brother looks great.
      #5
      Sleinous
      EVGA Forum Moderator
      • Total Posts : 7459
      • Reward points : 0
      • Joined: 2010/06/12 12:22:01
      • Location: Paris, France
      • Status: offline
      • Ribbons : 31
      Re:How-To: Live Folding Sig using HFM. 2011/01/23 02:50:14 (permalink)
      Coolios :D Only got one PC here so all is good with Tracker but if I ever expand out from my maxed out ASUS Rampage 3 then I will consider this :)

      My Affiliate Code: GL1IAAFWJF
      #6
      z3r0t0l0rence
      Omnipotent Enthusiast
      • Total Posts : 9579
      • Reward points : 0
      • Joined: 2009/10/08 10:14:51
      • Location: Undisclosed
      • Status: offline
      • Ribbons : 20
      Re:How-To: Live Folding Sig using HFM. 2011/01/23 11:24:22 (permalink)
      Nice work!  If I didn't already have my done I would be using this one for sure.

      i7 930 OC 4.21 
      EVGA E758 
      GSkill 12GB
      Evga GTX 780 SC
      2x Kingston 240 Raid 0
      2x Seagate 4TB
       
       
      #7
      Sleinous
      EVGA Forum Moderator
      • Total Posts : 7459
      • Reward points : 0
      • Joined: 2010/06/12 12:22:01
      • Location: Paris, France
      • Status: offline
      • Ribbons : 31
      Re:How-To: Live Folding Sig using HFM. 2011/01/23 12:14:58 (permalink)
      Is that sig also getting info froma status file or from EOC or something? Only just noticed the E and 187 near the front left wheel arch, whats that about? :P Also, is there not a Hall of Fame 5,000,000 badge, if there is I do believe you're now eligible :P

      My Affiliate Code: GL1IAAFWJF
      #8
      Bowenac
      CLASSIFIED ULTRA Member
      • Total Posts : 5642
      • Reward points : 0
      • Joined: 2007/10/25 23:40:18
      • Location: Puget Sound WA State
      • Status: offline
      • Ribbons : 17
      Re:How-To: Live Folding Sig using HFM. 2011/01/23 14:53:45 (permalink)
      z3r0t0l0rence

      Nice work!  If I didn't already have my done I would be using this one for sure.

      Yea I would be curious to know where or how you are pulling that data, and did you create a css or something for that font?
      #9
      z3r0t0l0rence
      Omnipotent Enthusiast
      • Total Posts : 9579
      • Reward points : 0
      • Joined: 2009/10/08 10:14:51
      • Location: Undisclosed
      • Status: offline
      • Ribbons : 20
      Re:How-To: Live Folding Sig using HFM. 2011/01/24 08:34:27 (permalink)
      My fellow Evo friend EVIIILJ designed it for me.  The 187 is my rank for the team(111065)EVGA.  As far as I know all info is ported from EOC.
       
      No 5mil badge.  Have to wait till 6!
      post edited by z3r0t0l0rence - 2011/01/24 08:35:31

      i7 930 OC 4.21 
      EVGA E758 
      GSkill 12GB
      Evga GTX 780 SC
      2x Kingston 240 Raid 0
      2x Seagate 4TB
       
       
      #10
      Sleinous
      EVGA Forum Moderator
      • Total Posts : 7459
      • Reward points : 0
      • Joined: 2010/06/12 12:22:01
      • Location: Paris, France
      • Status: offline
      • Ribbons : 31
      Re:How-To: Live Folding Sig using HFM. 2011/01/24 08:37:48 (permalink)
      Ah! Trendy! :P Well you'd best get that 780K folded then! :P

      My Affiliate Code: GL1IAAFWJF
      #11
      metal_god69
      FTW Member
      • Total Posts : 1602
      • Reward points : 0
      • Joined: 2008/04/22 23:48:01
      • Location: Regina, Canada
      • Status: offline
      • Ribbons : 2
      Re:How-To: Live Folding Sig using HFM. 2011/01/24 16:24:56 (permalink)
      I dig your folding sig z3r0t0l0rence

                                   
        
      #12
      z3r0t0l0rence
      Omnipotent Enthusiast
      • Total Posts : 9579
      • Reward points : 0
      • Joined: 2009/10/08 10:14:51
      • Location: Undisclosed
      • Status: offline
      • Ribbons : 20
      Re:How-To: Live Folding Sig using HFM. 2011/01/24 18:28:33 (permalink)
      Thanks bro. 

      i7 930 OC 4.21 
      EVGA E758 
      GSkill 12GB
      Evga GTX 780 SC
      2x Kingston 240 Raid 0
      2x Seagate 4TB
       
       
      #13
      brcromer
      CLASSIFIED Member
      • Total Posts : 4492
      • Reward points : 0
      • Joined: 2010/05/12 10:27:26
      • Location: Crazy Hippie land, Kansas(They're coming for you!)
      • Status: offline
      • Ribbons : 27
      Re:How-To: Live Folding Sig using HFM. 2011/01/24 18:53:15 (permalink)

      #14
      Tiger770
      SSC Member
      • Total Posts : 570
      • Reward points : 0
      • Joined: 2010/01/21 19:33:17
      • Status: offline
      • Ribbons : 7
      Re:How-To: Live Folding Sig using HFM. 2011/01/26 15:31:44 (permalink)
      Bowenac


      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: *.png
    • Module: FastCgiModule
    • Executable: "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.
    • I think this is for IIS 7.  I'm running IIS 6 on a 2k3 server.  Do you know where to add this in IIS 6?


      #15
      Tiger770
      SSC Member
      • Total Posts : 570
      • Reward points : 0
      • Joined: 2010/01/21 19:33:17
      • Status: offline
      • Ribbons : 7
      Re:How-To: Live Folding Sig using HFM. 2011/01/27 17:05:37 (permalink)
      I'm making progress on this, but I thought I would post here to let you know your PHP file has a syntax error on line 9.  The call to 'ppd' is not working, as it is case sensitive and should be 'PPD'.
       
      $newppd = $results['Instance'][$i]['ppd'];           
      should be 
      $newppd = $results['Instance'][$i]['PPD'];           

      post edited by Tiger770 - 2011/01/27 17:06:56


      #16
      Bowenac
      CLASSIFIED ULTRA Member
      • Total Posts : 5642
      • Reward points : 0
      • Joined: 2007/10/25 23:40:18
      • Location: Puget Sound WA State
      • Status: offline
      • Ribbons : 17
      Re:How-To: Live Folding Sig using HFM. 2011/01/27 18:13:26 (permalink)
      Tiger770

      I'm making progress on this, but I thought I would post here to let you know your PHP file has a syntax error on line 9.  The call to 'ppd' is not working, as it is case sensitive and should be 'PPD'.

      $newppd = $results['Instance'][$i]['ppd'];           
      should be 
      $newppd = $results['Instance'][$i]['PPD'];           

      Doesn't make a difference mine works just fine with lower case.
      #17
      clifford_cooley
      ACX Member
      • Total Posts : 469
      • Reward points : 0
      • Joined: 2010/11/03 18:40:27
      • Location: Arkansas, USA
      • Status: offline
      • Ribbons : 0
      Re:How-To: Live Folding Sig using HFM. 2011/01/27 18:38:45 (permalink)
      Bowenac
      Tiger770I'm making progress on this, but I thought I would post here to let you know your PHP file has a syntax error on line 9.  The call to 'ppd' is not working, as it is case sensitive and should be 'PPD'.

      $newppd = $results['Instance'][$i]['ppd'];           
      should be 
      $newppd = $results['Instance'][$i]['PPD'];           

      Doesn't make a difference mine works just fine with lower case.

       
      Since you are assigning $k a value for the clients data the code below is not used.
      $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;
      }}};

       
       
      post edited by clifford_cooley - 2011/01/27 18:44:31
      #18
      clifford_cooley
      ACX Member
      • Total Posts : 469
      • Reward points : 0
      • Joined: 2010/11/03 18:40:27
      • Location: Arkansas, USA
      • Status: offline
      • Ribbons : 0
      Re:How-To: Live Folding Sig using HFM. 2011/01/27 18:47:19 (permalink)
      I don't understand EVGA text editor. I'm constantly fighting where my cursor is located and can't seem to force the lines in the code box to use separate lines. The post above has half the code on separate lines and the other half all on one line. I have no idea why.
      #19
      Tiger770
      SSC Member
      • Total Posts : 570
      • Reward points : 0
      • Joined: 2010/01/21 19:33:17
      • Status: offline
      • Ribbons : 7
      Re:How-To: Live Folding Sig using HFM. 2011/01/28 07:55:03 (permalink)
      I've got the php info working, but for some reason I can't get it to append to my signature by inserting it with the image link.
       
      The picture comes up but when I save it the changes aren't made.
       
       
      I understand it needs to be in a *.png format but I guess my PHP isn't setup correctly, as the image shows as a PNG but the extension remains PHP.  Any thoughts?
       
      EDIT:
      I think I got it.
       

       
      Edit #2.
       
      Yep.  Awesome.....
      post edited by Tiger770 - 2011/01/28 12:48:50


      #20
      Bowenac
      CLASSIFIED ULTRA Member
      • Total Posts : 5642
      • Reward points : 0
      • Joined: 2007/10/25 23:40:18
      • Location: Puget Sound WA State
      • Status: offline
      • Ribbons : 17
      Re:How-To: Live Folding Sig using HFM. 2011/01/29 08:08:32 (permalink)
      Looks awesome tiger.
      #21
      metal_god69
      FTW Member
      • Total Posts : 1602
      • Reward points : 0
      • Joined: 2008/04/22 23:48:01
      • Location: Regina, Canada
      • Status: offline
      • Ribbons : 2
      Re:How-To: Live Folding Sig using HFM. 2011/01/29 09:15:30 (permalink)
      thats alot of clients u got there lol.  Looks great!!!

                                   
        
      #22
      unhappyelf
      ACX Member
      • Total Posts : 320
      • Reward points : 0
      • Joined: 2008/09/24 19:55:01
      • Location: Houston, Tx
      • Status: offline
      • Ribbons : 1
      Re:How-To: Live Folding Sig using HFM. 2011/01/29 11:02:27 (permalink)
      Looks good tiger.....I'm glad everyone took my idea and ran with it.


      #23
      clifford_cooley
      ACX Member
      • Total Posts : 469
      • Reward points : 0
      • Joined: 2010/11/03 18:40:27
      • Location: Arkansas, USA
      • Status: offline
      • Ribbons : 0
      Re:How-To: Live Folding Sig using HFM. 2011/02/28 18:59:06 (permalink)
      Bump for those that did not see this thread.
      #24
      Tiger770
      SSC Member
      • Total Posts : 570
      • Reward points : 0
      • Joined: 2010/01/21 19:33:17
      • Status: offline
      • Ribbons : 7
      Re:How-To: Live Folding Sig using HFM. 2011/03/01 13:30:02 (permalink)
      Does anyone know the XML Value for "Sending Work Packet" in HFM?  I noticed last night during a -bigadv upload (15 minutes) that my status is blank because there is no value for the status defined.
       
      I'm going to guess it's "SendingWorkPacket" but I'm not 100% sure.  Anyone know for sure or have a way to check?
       
      Edit:  I caught it on the next upload.  It is "SendingWorkPacket". 
      post edited by Tiger770 - 2011/03/02 14:30:56


      #25
      mcyhanick
      ACX Member
      • Total Posts : 358
      • Reward points : 0
      • Joined: 2009/12/06 08:44:52
      • Location: Reisterstown, MD
      • Status: offline
      • Ribbons : 1
      Re:How-To: Live Folding Sig using HFM. 2012/10/06 00:52:54 (permalink)
      does this even work anymore now that HFM works with v7?
      #26
      Tiger770
      SSC Member
      • Total Posts : 570
      • Reward points : 0
      • Joined: 2010/01/21 19:33:17
      • Status: offline
      • Ribbons : 7
      Re:How-To: Live Folding Sig using HFM. 2012/10/07 18:37:19 (permalink)
      Mine is working, but to be honest I'm still using the 6.34 client on a few systems, and the GPU Tracker v.2 on the others.  My XMLs are still being tracked and Generated with HFM.  I'd imagine that if you spent some time studying the XML output of the v7 client, you could adjust the code to accomodate for the new client version with little difficulty.
       
      I just don't run v7, so I'm not much help. :)
       
      Edit:  The only think I think you'll need to do is make sure you're still running an older version of HFM for the bulk of this code to work.  It's based on the "Overview.XML" output by versions from 0.6.2 HFM and back.  I updated to 0.9.1 and there's a new XML format and filename called SlotSummary.XML which has a different structure altogether.   So I rolled back to 0.6.2 and all was right again.
      post edited by Tiger770 - 2012/10/07 19:35:48


      #27
      mcyhanick
      ACX Member
      • Total Posts : 358
      • Reward points : 0
      • Joined: 2009/12/06 08:44:52
      • Location: Reisterstown, MD
      • Status: offline
      • Ribbons : 1
      Re:How-To: Live Folding Sig using HFM. 2012/10/08 03:57:23 (permalink)
      Looks like I will need to get this figured out if anyone wishes to upgrade to the newer version.
      #28
      mcyhanick
      ACX Member
      • Total Posts : 358
      • Reward points : 0
      • Joined: 2009/12/06 08:44:52
      • Location: Reisterstown, MD
      • Status: offline
      • Ribbons : 1
      Re:How-To: Live Folding Sig using HFM. 2012/10/08 21:49:56 (permalink)
      figured it out, just needed to modify the php code to read the new xml format that HFM 0.9.1 exports
      <?php       
       
       $results = simpleXMLToArray(simplexml_load_file("SlotSummary.xml"));      
       
       $oldppd=0;      
       $k=0;      
       $onoff=0;      
       for($i=0 ;$i<=9;$i++){      
           $newppd = $results['Slots']['SlotData'][$i]['GridData']['PPD'];      
           if($newppd > $oldppd){      
               $oldppd=$newppd;      
               $k=$i;      
           }      
       }      
       if($k == 0){      
           for($i=0 ;$i<=9;$i++){      
               if($results['Slots']['SlotData'][$i]['GridData']['Credit'] > 0){      
                   $k=$i;      
               }      
           }      
       }      
       
       $image = "background.png";       
       $im = imagecreatefrompng($image);      
       $wc = ImageColorAllocate ($im, 255, 255, 255);
       $black = ImageColorAllocate ($im, 0, 0, 0);
       $green = ImageColorAllocate ($im, 0, 255, 0);      
       $red = ImageColorAllocate ($im, 223, 56, 5);      
       $yellow = ImageColorAllocate ($im, 255, 255, 0);      
       if($results['Slots']['SlotData'][$k]['GridData']['Status'] == "Running"){ImageString($im, 35, 530, 10, "Running", $green);}      
       if($results['Slots']['SlotData'][$k]['GridData']['Status'] == "Paused"){ImageString($im, 35, 530, 10, "Paused", $yellow);}      
       if($results['Slots']['SlotData'][$k]['GridData']['Status'] == "Stopped"){ImageString($im, 35, 530, 10, "Stopped", $red);}      
       if($results['Slots']['SlotData'][$k]['GridData']['Status'] == "Disabled"){ImageString($im, 35, 530, 10, "Disabled", $wc);}      
       ImageString($im, 35, 300, 10, $results['Slots']['SlotData'][$k]['GridData']['Name'], $black);      
       ImageString($im, 4, 262, 60, $results['Slots']['SlotData'][$k]['GridData']['ProjectRunCloneGen'], $black);       
       ImageString($im, 4, 328, 60, $results['Slots']['SlotData'][$k]['GridData']['Credit'], $black);       
       ImageString($im, 4, 402, 60, $results['Slots']['SlotData'][$k]['GridData']['PercentComplete'], $black);       
       ImageString($im, 4, 475, 60, $results['Slots']['SlotData'][$k]['GridData']['PPD'], $black);      
       ImageString($im, 4, 555, 60, $results['Slots']['SlotData'][$k]['GridData']['TPF'], $black);      
       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;      
           }      
       
       ?>

      post edited by mcyhanick - 2012/10/08 21:56:24
      #29
      Jump to:
    • Back to Mobile