Play images and video from Synology PhotoStation server

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. class WebAPIUtil {
  3. static function Log($text = "", $file_name = "", $line = "0") {
  4. if ("" === $text) {
  5. return;
  6. }
  7. $file_name = basename($file_name);
  8. syslog(LOG_ERR, "$file_name:$line $text");
  9. }
  10. static function ParseToArray($string, $separator) {
  11. $result = array();
  12. foreach (explode($separator, $string) as $element) {
  13. $trimmed = trim($element);
  14. if (!empty($trimmed)) {
  15. $result[] = $trimmed;
  16. }
  17. }
  18. return $result;
  19. }
  20. static function ParseAuthKey($authkey) {
  21. $auth_arr = json_decode(WebAPIUtil::Decrypt($authkey), true);
  22. $ret = false;
  23. if (null === $auth_arr) {
  24. goto End;
  25. }
  26. if (!isset($auth_arr['myds_id']) || !isset($auth_arr['app_id']) || !isset($auth_arr['time'])) {
  27. goto End;
  28. }
  29. $ret = $auth_arr;
  30. End:
  31. return $ret;
  32. }
  33. static function Encrypt($str) {
  34. // Charlie temp - wait to implement
  35. return base64_encode($str);
  36. }
  37. static function Decrypt($str) {
  38. // Charlie temp - wait to implement
  39. return base64_decode($str);
  40. }
  41. static function IsEMail($email) {
  42. $pattern = '/^[a-zA-Z0-9_&%!#+-\.]+@([a-zA-Z0-9_&%!#+-\.]+)$/';
  43. if (preg_match($pattern, $email)) {
  44. return true;
  45. } else {
  46. return false;
  47. }
  48. }
  49. }
  50. ?>