/webservices/ws_GetVODMoviesBySubcategory.php

https://github.com/thekidrobot/adminSite · PHP · 157 lines · 97 code · 22 blank · 38 comment · 9 complexity · 64d9781f24363d6ec1776b1fd2eaede9 MD5 · raw file

  1. <?php
  2. session_start();
  3. // incluir libreria nusoap
  4. require_once('conexion.inc.php');
  5. require_once('lib/nusoap.php');
  6. // Crear server
  7. $soap_server = new nusoap_server();
  8. $page = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  9. $page = 'http://'.substr($page,0,strrpos($page,"/"));
  10. $ns = $page;
  11. // configurar WSDL
  12. $soap_server->configureWSDL('WDSL Authentication', $ns);
  13. // registrar función
  14. $soap_server->register
  15. (
  16. 'receiveUserData',
  17. array('userid' => 'xsd:string','id' => 'xsd:string'),
  18. array('return' => 'xsd:string'),
  19. $ns,
  20. $ns.'#receiveUserData',
  21. 'rpc',
  22. 'encoded',
  23. 'ReceiveUserId'
  24. );
  25. function receiveUserData($userid='',$id='')
  26. {
  27. $arr_msg = array('status'=> '');
  28. $user = array();
  29. $channels = array();
  30. $sql = "/*SELECT DISTINCT
  31. vc.id AS id,
  32. vcc.category_id AS categoryId,
  33. vc.local_url AS local_url,
  34. vc.stb_url AS stb_url,
  35. vc.description AS description,
  36. vc.name AS name,
  37. vc.keywords AS keywords,
  38. vc.date_release AS date_release,
  39. vc.small_pic AS poster,
  40. vc.big_pic AS posterLarge,
  41. vct.parent AS parentId
  42. FROM
  43. vodchannels vc,
  44. packages_vodchannels pv,
  45. subscribers sc,
  46. subscribers_packages sp,
  47. vod_channels_categories vcc,
  48. vodcategories vct
  49. WHERE
  50. vc.id = vcc.channel_id AND
  51. pv.resource_id = vc.id AND
  52. pv.package_id = sp.package_id AND
  53. sp.subscriber_id = sc.id AND
  54. vct.id = vcc.category_id AND
  55. sc.pin = '$userid' AND
  56. vct.id = $id
  57. UNION */
  58. SELECT DISTINCT
  59. vc.id AS id,
  60. vcc.category_id AS categoryId,
  61. vc.local_url AS local_url,
  62. vc.stb_url AS stb_url,
  63. vc.description AS description,
  64. vc.name as name,
  65. vc.keywords AS keywords,
  66. vc.date_release AS date_release,
  67. vc.small_pic AS poster,
  68. vc.big_pic AS posterLarge,
  69. vct.parent AS parentId
  70. FROM
  71. vodchannels vc,
  72. packages_vodchannels pv,
  73. subscribers sc,
  74. subscribers_packages sp,
  75. vod_channels_categories vcc,
  76. vodcategories vct
  77. WHERE
  78. vc.id = vcc.channel_id AND
  79. pv.resource_id = vc.id AND
  80. pv.package_id = sp.package_id AND
  81. sp.subscriber_id = sc.id AND
  82. vct.id = vcc.category_id AND
  83. sc.pin = '$userid' AND
  84. vct.parent = $id";
  85. $result = mysql_query($sql);
  86. if(mysql_num_rows($result) == 0)
  87. {
  88. $arr_msg['status'] = 'success';
  89. $arr_msg['movies'] = '';
  90. }
  91. else
  92. {
  93. while($row = mysql_fetch_object($result))
  94. {
  95. $show = true;
  96. //Restriction by max. views
  97. if($row->max_views != 0 and ($row->max_views > $row->current_views))
  98. {
  99. $show = false;
  100. }
  101. //Restriction by date
  102. if($row->duration != 0)
  103. {
  104. $restriction_date = strtotime($row->restriction_date);
  105. $now = strtotime($row->today);
  106. if ($restriction_date < $now){
  107. $show = false;
  108. }
  109. }
  110. if($show == true){
  111. array_push
  112. ($channels,$user['vodId'] = trim($row->id),$user['categoryId'] = trim($row->categoryId),
  113. $user['localURL'] = trim($row->local_url),$user['remoteURL'] = trim($row->stb_url),
  114. $user['description'] = trim($row->description),$user['name'] = trim($row->name),
  115. $user['poster']=trim($row->poster),$user['posterLarge']=trim($row->posterLarge),$user['parentId']=trim($row->parentId));
  116. $usuario.=json_encode($user).',';
  117. }
  118. }
  119. $usuario = "[".substr($usuario,0,strlen($usuario)-1)."]";
  120. $arr_msg['status'] = 'success';
  121. $arr_msg['movies'] = $usuario;
  122. }
  123. $usuario = str_replace('\\','',json_encode($arr_msg));
  124. $usuario = str_replace('"[','[',$usuario);
  125. $usuario = str_replace(']"',']',$usuario);
  126. return $usuario;
  127. }
  128. $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
  129. $soap_server->service($HTTP_RAW_POST_DATA);
  130. ?>