fuel9 / DisplayMonkey

Display Monkey digital signage solution
Other
126 stars 50 forks source link

PHP script not working #78

Open BobbyOfWindsor1974 opened 5 years ago

BobbyOfWindsor1974 commented 5 years ago

Hi, I have PHP installed in the server and if I load the page from the DisplayMonkey folder it works great. If I let DisplayMonkey show the page in the main display, the script shows as text. How can I tell DM to parse/run the php script?

The script changes the fill on the triangles based on accidents and serverity. The images shown are one from in DM and the other is direct via a web browser through IIS. dm_notworking dm_working

Here is the code. <!DOCTYPE html PUBLIC "-/ung/W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Untitled Document
  Incident Report
  Fatality    
  Maimed      
  Injuries other than above      
  Near misses      
  No issues      
Daily Safety Pyramid
October 2018
load($inputFileName); // Use the PHPExcel object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook class MyReadFilter implements PHPExcel_Reader_IReadFilter { private $_startRow = 0; private $_endRow = 0; private $_columns = array(); // Get the list of rows and columns to read public function __construct($startRow, $endRow, $columns) { $this->_startRow = $startRow; $this->_endRow = $endRow; $this->_columns = $columns; } public function readCell($column, $row, $worksheetName = '') { // Only read the rows and columns that were configured if ($row >= $this->_startRow && $row <= $this->_endRow) { if (in_array($column,$this->_columns)) { return true; } } return false; } } // We are only interested in the date and status columns. Data is in the format d-mmmm and stuats. $filterSubset = new MyReadFilter(1,34, range('A', 'B')); // Look for the status sheet only. $sheetNames = $objPHPExcel->getSheetNames(); foreach($sheetNames as $sheetIndex => $sheetName) { if(strtoupper($sheetName) == INTERESTING_SHEET) { $objReader->setReadDataOnly(true); $objReader->setReadFilter($filterSubset); $objReader->setLoadSheetsOnly($sheetName); $objPHPExcel = $objReader->load($inputFileName); $objWorksheet = $objPHPExcel->setActiveSheetIndexByName($sheetName); // Loop through data $highestRow = $objWorksheet->getHighestRow(); // e.g. 10 $highestColumn = $objWorksheet->getHighestColumn(); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); // e.g. 5 for ($row = 1; $row <= $highestRow; ++$row) { for ($col = 0; $col <= $highestColumnIndex; ++$col) { $val = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); if ($col==0 && is_numeric($val)) { $newclass = NO_CLASS; $day = trim(date('d', PHPExcel_Shared_Date::ExcelToPHP(trim($val))) * 1); // Get status data. $val = strtoupper($objWorksheet->getCellByColumnAndRow($col + 1, $row)->getValue()); // Set class based on status. switch($val) { case NO_ISSUES_STATUS; $newclass = NO_ISSUES_CLASS; break; case NEAR_MISSES_STATUS; $newclass = NEAR_MISSES_CLASS; break; case FATALITY_STATUS; $newclass = FATALITY_CLASS; break; case MAIMED_STATUS; $newclass = MAIMED_CLASS; break; case INJURIES_OTHER_STATUS; $newclass = INJURIES_OTHER_CLASS; break; } echo sprintf('', $day, $newclass); } } } } } ?>
michaelmalmgren commented 5 years ago

Hi Bobby, I'm not sure I understand what is going on here. Are you referencing a URL in a DM HTML iframe that contains a PHP-script?

BobbyOfWindsor1974 commented 5 years ago

Yes the frame.

[cid:image001.png@01D46C2E.CD15CB40]

[cid:image002.png@01D46C2E.CD15CB40]

PHP script embeded in the html does not work here.

Thanks

--Bobby

Robert Hicks | Senior Technical Analyst, Schukra - Leggett & Platt Automotive Group- North America 360 Silvercreek Industrial Dr., Lakeshore, ON N8N 4Y3 | •: 519-727-7000 Ext. 1003 | : 519-817-1576 | 7: 519-727-7068| •: bobby.hicks@leggett.commailto:bobby.hicks@leggett.com Website: www.leggett-automotive.com [Description: Description: facebook tiny] https://www.facebook.com/LeggettAuto [Description: Description: insta tiny] https://www.linkedin.com/company-beta/9362272 [Description: Description: linked in tiny] https://www.linkedin.com/company-beta/9362272 [Description: Description: twitter tiny] https://www.twitter.com/leggettauto/ P Please consider your environmental responsibility before printing this e-mail

From: Michael Malmgren [mailto:notifications@github.com] Sent: Thursday, October 25, 2018 3:02 AM To: fuel9/DisplayMonkey Cc: Bobby Hicks; Author Subject: [EXTERNAL] Re: [fuel9/DisplayMonkey] PHP script not working (#78)

Hi Bobby, I'm not sure I understand what is going on here. Are you referencing a URL in a DM HTML iframe that contains a PHP-script?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_fuel9_DisplayMonkey_issues_78-23issuecomment-2D432937590&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=TaU9Uw2lqdmQBB8UTy5rTnC5f1G3e3jTLxrdI73g1nA&s=Em2rz9xi2c1w-09iYbewdzuc_eQvWs_mRjy-X78HCRc&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AoHkmKEAk0hN-2DX7Lzxq9vq8hZHW4VitJks5uoWH5gaJpZM4X4OVG&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=TaU9Uw2lqdmQBB8UTy5rTnC5f1G3e3jTLxrdI73g1nA&s=Kd7wuwK0OFNqwCSf07miWwnXNEpiTEEWbX_Ck_6e048&e=.

michaelmalmgren commented 5 years ago

Bobby, try instead to link in your PHP page as an HTML IFRAME inside the DM HTML frame. I.e. leave your PHP page on a PHP server and link it something like this

BobbyOfWindsor1974 commented 5 years ago

Thanks Michael. I’ll give it a try and let you know. Your help is appreciated.

Thanks

--Bobby

Robert Hicks | Senior Technical Analyst, Schukra - Leggett & Platt Automotive Group- North America 360 Silvercreek Industrial Dr., Lakeshore, ON N8N 4Y3 | •: 519-727-7000 Ext. 1003 | : 519-817-1576 | 7: 519-727-7068| •: bobby.hicks@leggett.commailto:bobby.hicks@leggett.com Website: www.leggett-automotive.com [Description: Description: facebook tiny] https://www.facebook.com/LeggettAuto [Description: Description: insta tiny] https://www.linkedin.com/company-beta/9362272 [Description: Description: linked in tiny] https://www.linkedin.com/company-beta/9362272 [Description: Description: twitter tiny] https://www.twitter.com/leggettauto/ P Please consider your environmental responsibility before printing this e-mail

From: Michael Malmgren [mailto:notifications@github.com] Sent: Thursday, October 25, 2018 8:14 AM To: fuel9/DisplayMonkey Cc: Bobby Hicks; Author Subject: [EXTERNAL] Re: [fuel9/DisplayMonkey] PHP script not working (#78)

Bobby, try instead to link in your PHP page as an HTML IFRAME inside the DM HTML frame. I.e. leave your PHP page on a PHP server and link something like this https://urldefense.proofpoint.com/v2/url?u=https-3A__myphp-5Fserver_myphp-5Fpage.php-2522-253E-253C_iframe-253E&d=DwQCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=76kTSH-F21fBzCYxsEO-c3RxGJxs5yGN3-792hiOxr4&s=sJm9FSM5nScvYPpZY8ZTHfyzD6Pw8WDG67U7eto5F0k&e=

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_fuel9_DisplayMonkey_issues_78-23issuecomment-2D433026832&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=76kTSH-F21fBzCYxsEO-c3RxGJxs5yGN3-792hiOxr4&s=PD_lh4syWotNBVj0G9wK7zcaGFNeMxx_nr3R6ma29Ro&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AoHkmMibdDKMj2s6fhUvsD-2DUpZmjBBiPks5uoar-2DgaJpZM4X4OVG&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=76kTSH-F21fBzCYxsEO-c3RxGJxs5yGN3-792hiOxr4&s=ZZfLrD9Qt8SJzNBoYLx-grCCmUfk4vqZu3cEoEZmvVI&e=.

psined1 commented 5 years ago

I assume your PHP page will be served from a different URL base. This can be a CORS challenge in many different browsers...

BobbyOfWindsor1974 commented 5 years ago

Yes. We have PHP setup on IIS and going directly to the .html file with embedded php, it works. Only when we add the contents to the HTML container in DM does it now work.

Thanks

--Bobby

Robert Hicks | Senior Technical Analyst, Schukra - Leggett & Platt Automotive Group- North America 360 Silvercreek Industrial Dr., Lakeshore, ON N8N 4Y3 | •: 519-727-7000 Ext. 1003 | : 519-817-1576 | 7: 519-727-7068| •: bobby.hicks@leggett.commailto:bobby.hicks@leggett.com Website: www.leggett-automotive.com [Description: Description: facebook tiny] https://www.facebook.com/LeggettAuto [Description: Description: insta tiny] https://www.linkedin.com/company-beta/9362272 [Description: Description: linked in tiny] https://www.linkedin.com/company-beta/9362272 [Description: Description: twitter tiny] https://www.twitter.com/leggettauto/ P Please consider your environmental responsibility before printing this e-mail

From: Denis P. [mailto:notifications@github.com] Sent: Thursday, October 25, 2018 9:36 AM To: fuel9/DisplayMonkey Cc: Bobby Hicks; Author Subject: [EXTERNAL] Re: [fuel9/DisplayMonkey] PHP script not working (#78)

I assume your PHP page will be served from a different URL base. This can be a CORShttps://urldefense.proofpoint.com/v2/url?u=https-3A__developer.mozilla.org_en-2DUS_docs_Web_HTTP_CORS&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=1f_Uh7t6gBFIvqY6EfJBc8_iPUDcfkHAWgZckCQJD1M&s=mYqOaWTOMXPLcOAprpuKLLpr8UeG8YG9fqnOXRjHGJY&e= challenge in many different browsers...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_fuel9_DisplayMonkey_issues_78-23issuecomment-2D433053541&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=1f_Uh7t6gBFIvqY6EfJBc8_iPUDcfkHAWgZckCQJD1M&s=mO6d9_IFft14-B4D-DSxHbpSLyhoRNr6KWceNZg8Jsg&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AoHkmME4Z-5FpR8JiTogJGQ22PUNlPDId5ks5uob48gaJpZM4X4OVG&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=1f_Uh7t6gBFIvqY6EfJBc8_iPUDcfkHAWgZckCQJD1M&s=Vdb94HLaVcIUEtPhW1KsZCbv5iUrZaim9gNH4tEOLXo&e=.

psined1 commented 5 years ago

Well, as I said, CORS might be your culprit..

BobbyOfWindsor1974 commented 5 years ago

We have cors set so we can pull RSS feeds. It behaves like it doesn’t see the pho script.

Sent from my iPhone

On Oct 25, 2018, at 10:06 AM, Denis P. notifications@github.com<mailto:notifications@github.com> wrote:

Well, as I said, CORS might be your culprit..

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_fuel9_DisplayMonkey_issues_78-23issuecomment-2D433064652&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=IR0EOfH6Fw7CabUx6evZsdpPrprh0MIf7MHmhXVnCyY&s=VIYIu6qu0_0EBG3KPhe2dlBQt8OHQFwElFtwSqnMUtI&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AoHkmOp9iPUw5rByu6z-5Fb2FaMqK4VU8uks5uocVLgaJpZM4X4OVG&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=IR0EOfH6Fw7CabUx6evZsdpPrprh0MIf7MHmhXVnCyY&s=99SJ91PrBjB0i-KYKY5BP0nvsN6zLktBRwnOYkGAgQA&e=.

psined1 commented 5 years ago

Looks like DM might be downloading your PHP script as a text, rather than executing it on the server. Have you tried HTML frame suggestion from @michaelmalmgren ?

BobbyOfWindsor1974 commented 5 years ago

I think so as well. It’s not seeing it as php. The frame with an external HTML/php works well.

Sent from my iPhone

On Nov 12, 2018, at 4:58 PM, Denis P. notifications@github.com<mailto:notifications@github.com> wrote:

Looks like DM might be downloading your PHP script as a text, rather than executing it on the server. Have you tried HTML frame suggestion from @michaelmalmgrenhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_michaelmalmgren&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=lRXoPwEBxLQOo-WlVklutF6zCvLxh1krytx7U3tgpCA&s=YinPXBDrr2l-q-440FHCgj2xX7hNgT-ga3FKzH6dnWQ&e= ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_fuel9_DisplayMonkey_issues_78-23issuecomment-2D438042889&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=lRXoPwEBxLQOo-WlVklutF6zCvLxh1krytx7U3tgpCA&s=opQTluADeisIrNUu9PgDn9FpajZrkqf322H-VMoTCtE&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AoHkmJwu49bl7G7gurps8PoGFjhf3DS7ks5uue8MgaJpZM4X4OVG&d=DwMCaQ&c=y2CoG5YnjIJpazuVfWQ7cQ&r=VSK8zsTMB9_o0CyFtzVnI7KU3082pv11Dn5l0G4nfiY&m=lRXoPwEBxLQOo-WlVklutF6zCvLxh1krytx7U3tgpCA&s=uYv34M9VQ2hebZdd4o0SKVYrgiKr31dlupUfrOf06PM&e=.