Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wake-on-lan.php not working on PHP 8.x #15

Open
antmarortega opened this issue Jul 8, 2023 · 2 comments
Open

Wake-on-lan.php not working on PHP 8.x #15

antmarortega opened this issue Jul 8, 2023 · 2 comments

Comments

@antmarortega
Copy link

Considering Wake-on-lan.php might be pre PHP 8, it seems logical it is not working on PHP 8.x.
I myself had to rewrite several PHP 7 scripts to work with PHP8 again,
You get errors when saving the configuration file (alas I did not write the errors down).
I immediately installed Xamp 7.x instead and it worked.

@AndiSHFR
Copy link
Owner

AndiSHFR commented Jul 9, 2023

Thank you for this information.
I will have a look at it.

@mae1cum77
Copy link

Script getting utf8_encoding() is deprecated message in PHP 8.x, not working due to it.

function endWithJsonResponse($responseData, $filename = NULL) {

  if($responseData) {
    array_walk_recursive($responseData, function(&$value, &$key) {
      if(is_string($value)) $value = utf8_encode($value);
    });  
  }

Needs to be changed to:

function iso8859_1_to_utf8(string $s): string {
  $s .= $s;
  $len = \strlen($s);

  for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) {
      switch (true) {
          case $s[$i] < "\x80": $s[$j] = $s[$i]; break;
          case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break;
          default: $s[$j] = "\xC3"; $s[++$j] = \chr(\ord($s[$i]) - 64); break;
      }
  }

  return substr($s, 0, $j);
}

function endWithJsonResponse($responseData, $filename = NULL) {

  if($responseData) {
    array_walk_recursive($responseData, function(&$value, &$key) {
      if(is_string($value)) $value = iso8859_1_to_utf8($value);
    });  
  }

I can now use it on my Android 13 device :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants