Jump to content

Ocean Blue v3.0.1 coding problem w/ php 7.2


Recommended Posts

Posted
8 hours ago, ProAvia said:

What version of phpVMS are you using?

What PHP version are you using? I'm betting version 7.x 

How to solve the "Warning: count (): Parameter must be ..." problem
I did a google search and many websites have this error. Surely they have installed higher php7.x on their servers
I remember I said making a change

  • Administrators
Posted

Your warning error is NOT caused by the skin you are using.... it is because of changes between PHP 5.6 and PHP 7.2

For front_page main.php line 157 - replace the "<?php ... ?>" section with

<?php if(is_array(ACARSData::GetACARSData()) || (ACARSData::GetACARSData()) instanceof Countable) {
	echo count(ACARSData::GetACARSData());
}?>

I don't have frontpage_map.php line 17 in front of me right now, but the fix is very similar to the above

<?php if(is_array(...call after 'count') || (...call after 'count') instanceof Countable) {
     .... probably an echo line;
}?>

If you need the fix for frontpage_map.php to be more specific, you will need to post the code for that line here first.

Chances are you may encounter these 'count' warning errrors again in different modules. For the most part, the fix is the same.

The above changes only apply to PHP 7 and above.

  • Administrators
Posted

You need to re-read my reply above ..... there are 2 files to edit...

frontpage_main.php and frontpage_map.php - two different files.... MAIN and MAP

frontpage_main.php gets the first edit

frontpage_map.php  - you need to edit the contents as directed - along the same lines as the first file.... I used fake names for the calls cause I didn't have the file available this morning.

Replace lines 16-56

<?php
if(count($pireps) > 0)
{
  foreach ($pireps as $pirep)
  {
    $pilotinfo = PilotData::getPilotData($pirep->pilotid);
    $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);
    $acrid = OperationsData::getAircraftByReg($pirep->registration);

    echo '<tr>';
    echo '<td><a href="'.SITE_URL.'/index.php/profile/view/'.$pilotinfo->pilotid.'">'.$pilotinfo->firstname.' '.$pilotinfo->lastname[0].'.</a></td>';
    echo '<td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>';
    echo '<td>'.$pirep->depicao.'</td>';
    echo '<td>'.$pirep->arricao.'</td>';
    echo '<td>'.$pirep->aircraft.'</td>';
    echo '<td>'.$pirep->flighttime.'</td>';
    echo '<td>'.$pirep->landingrate.' ft/m</td>';

if($pirep->accepted == PIREP_ACCEPTED)

echo '<td><button type="button" class="btn btn-outline btn-success btn-xs mb-2">Flight Approved</button></td>';

                                elseif($pirep->accepted == PIREP_REJECTED)

echo '<td><button type="button" class="btn btn-outline btn-danger btn-xs mb-2">Flight Rejected</button></td>';

                                elseif($pirep->accepted == PIREP_PENDING)

echo '<td><button type="button" class="btn btn-outline btn-primary btn-xs mb-2">Approval Pending</button></td>';

                                elseif($pirep->accepted == PIREP_INPROGRESS)

echo '<td><button type="button" class="btn btn-outline btn-primary btn-xs mb-2">On Progress</button></td>';
    echo '</tr>';
  }
}
else
{
    echo '<tr><td>There are no recent flights!</td></tr>';
}
?>

With this

<?php
if(is_array($pireps) || ($pireps) instanceof Countable
{
  if(count($pireps) > 0)
  {
    foreach ($pireps as $pirep)
    {
      $pilotinfo = PilotData::getPilotData($pirep->pilotid);
      $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);
      $acrid = OperationsData::getAircraftByReg($pirep->registration);

      echo '<tr>';
      echo '<td><a href="'.SITE_URL.'/index.php/profile/view/'.$pilotinfo->pilotid.'">'.$pilotinfo->firstname.' '.$pilotinfo->lastname[0].'.</a></td>';
      echo '<td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>';
      echo '<td>'.$pirep->depicao.'</td>';
      echo '<td>'.$pirep->arricao.'</td>';
      echo '<td>'.$pirep->aircraft.'</td>';
      echo '<td>'.$pirep->flighttime.'</td>';
      echo '<td>'.$pirep->landingrate.' ft/m</td>';

  	if($pirep->accepted == PIREP_ACCEPTED)

      echo '<td><button type="button" class="btn btn-outline btn-success btn-xs mb-2">Flight Approved</button></td>';

    elseif($pirep->accepted == PIREP_REJECTED)

      echo '<td><button type="button" class="btn btn-outline btn-danger btn-xs mb-2">Flight Rejected</button></td>';

    elseif($pirep->accepted == PIREP_PENDING)

      echo '<td><button type="button" class="btn btn-outline btn-primary btn-xs mb-2">Approval Pending</button></td>';

    elseif($pirep->accepted == PIREP_INPROGRESS)

      echo '<td><button type="button" class="btn btn-outline btn-primary btn-xs mb-2">On Progress</button></td>';
    echo '</tr>';
    }
  }
  else
  {
      echo '<tr><td>There are no recent flights!</td></tr>';
  }
}
?>

So I think you may need to revert to the original files first and then edit the TWO files again. Hopefully your renamed the originals before saving the edit - if not, you can get the originals from the skin download. Sorry for any confusion on the second edit.

The edit to the frontpage_map.php file should work - but I have no way to try it. I had to do the edit to frontpage_main.php on another site that was using php 7.2 and an older version of the Ocean Blue skin.

Let us know how it works out.

  • Administrators
Posted

Well... let's try this then....

Near the end of frontpage_map.php...... change

echo '</tr>';
    }
  }
  else
  {
      echo '<tr><td>There are no recent flights!</td></tr>';
  }
}
?>

To this

echo '</tr>';
    }
  }
}
  else
  {
      echo '<tr><td>There are no recent flights!</td></tr>';
  }
?>

Basically, you are moving the last ' } ' to just before 'else'.

Let us know how that works.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...