index.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. if (cfr('PROCRAST')) {
  3. //CDN invokable apps here
  4. $cachingTimeout = 86400;
  5. $cdnUrl = 'https://cdn.ubilling.net.ua/';
  6. $routeList = '?list=true';
  7. $routeInvoke = '?module=procrast&rinvoke=';
  8. $cache = new UbillingCache();
  9. $invocableApps = $cache->get('INVPROCR', $cachingTimeout);
  10. if (empty($invocableApps)) {
  11. $invocableApps = array();
  12. $cdn = new OmaeUrl($cdnUrl . $routeList);
  13. $ubVer = file_get_contents('RELEASE');
  14. $agent = 'ProcrastUbilling/' . trim($ubVer);
  15. $cdn->setUserAgent($agent);
  16. $rawInvokeData = $cdn->response();
  17. if (!empty($rawInvokeData)) {
  18. @$jsonValidity = json_decode($rawInvokeData, true);
  19. if (is_array($jsonValidity)) {
  20. $invocableApps = $jsonValidity;
  21. }
  22. }
  23. $cache->set('INVPROCR', $invocableApps, $cachingTimeout);
  24. }
  25. if (ubRouting::checkGet('rinvoke')) {
  26. //invoking remote app here
  27. $remoteInvokedApp = ubRouting::get('rinvoke', 'vf');
  28. if (isset($invocableApps[$remoteInvokedApp])) {
  29. $appData = $invocableApps[$remoteInvokedApp];
  30. if ($appData) {
  31. $invokeCode = '';
  32. $style = 'style="width: 70vw; height: 70vh;"';
  33. if (ispos($appData['params'],'CUSTOMVIEW:')) {
  34. $style=str_replace('CUSTOMVIEW:','',$appData['params']);
  35. }
  36. $options = 'id="dos" src="' . $cdnUrl . $appData['url'] . '" frameborder="0" ' . $style . ' allowfullscreen';
  37. $invokeCode .= wf_tag('iframe', false, '', $options);
  38. $invokeCode .= wf_tag('iframe', true);
  39. $invokeCode .= wf_tag('script', false) . ' document.getElementById("dos").focus(); ' . wf_tag('script', true);
  40. show_window(__($appData['name']), $invokeCode);
  41. }
  42. } else {
  43. show_error(__('Strange exception'));
  44. }
  45. show_window('', wf_BackLink('?module=procrast'));
  46. } else {
  47. //rendering apps list
  48. $applicationsList = '';
  49. if (!empty($invocableApps)) {
  50. foreach ($invocableApps as $io => $each) {
  51. $applicationsList .= zb_buildGameIcon($routeInvoke . $io, $cdnUrl . $each['icon'], $each['name']);
  52. }
  53. }
  54. $applicationsList .= wf_CleanDiv();
  55. show_window(__('Procrastination helper'), $applicationsList);
  56. }
  57. zb_BillingStats(true);
  58. } else {
  59. show_error(__('Access denied'));
  60. }