Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. <?php
  2.  
  3. // paramètres
  4. $myhost = "192.168.1.1"; //adresse IP de votre livebox sur le réseau local
  5. $myusername = "admin"; //login pour accéder à la console d'administration de la livebox
  6. $mypassword = "4654A366"; //password pour accéder à la console d'administration de la livebox.
  7.  
  8. // authentification
  9. $headers = array("Content-Type: application/json");
  10. $response = httpQuery("http://".$myhost."/authenticate?username=".$myusername."&password=".$mypassword,"POST",null,null,$headers,true);
  11. $json = sdk_json_decode($response);
  12.  
  13. /*echo "<xmp>";
  14. var_dump($json);
  15. echo "</xmp>";*/
  16.  
  17. if ($json['status'] != '')
  18. {
  19. die("Erreur lors de l'authentification: <b>".$json['status']."</b>");
  20. }
  21. if (isset($json['data']['contextID']))
  22. {
  23. $access_token = $json['data']['contextID'];
  24. }
  25.  
  26. //recupération des infos de connexion
  27. $headers = array("Content-Type: application/json","X-Context: ".$access_token);
  28.  
  29. switch($_GET['action']){
  30.  
  31. case 'wifistate':
  32. $response = httpQuery("http://".$myhost."/sysbus/NMC/Wifi:get","POST",'{"parameters":{}}',null,$headers,true);
  33. //$json = sdk_json_decode($response);
  34. echo $response;
  35. break;
  36.  
  37. case 'lanstate':
  38. $response = httpQuery("http://".$myhost."/sysbus/NeMo/Intf/lan:getMIBs","POST",'{"parameters":{}}',null,$headers,true);
  39. echo $response;
  40. break;
  41.  
  42. case 'dslstate':
  43. $response = httpQuery("http://".$myhost."/sysbus/NeMo/Intf/dsl0:getDSLStats","POST",'{"parameters":{}}',null,$headers,true);
  44. echo $response;
  45. break;
  46.  
  47. case 'users':
  48. $response = httpQuery("http://".$myhost."/sysbus/UserManagement:getUsers","POST",'{"parameters":{}}',null,$headers,true);
  49. echo $response;
  50. break;
  51.  
  52. case 'iplan':
  53. $response = httpQuery("http://".$myhost."/sysbus/NeMo/Intf/lan:luckyAddrAddress","POST",'{"parameters":{}}',null,$headers,true);
  54. echo $response;
  55. break;
  56.  
  57. case 'ipwan':
  58. $response = httpQuery("http://".$myhost."/sysbus/NeMo/Intf/data:luckyAddrAddress","POST",'{"parameters":{}}',null,$headers,true);
  59. echo $response;
  60. break;
  61.  
  62. case 'wanstate':
  63. $response = httpQuery("http://".$myhost."/sysbus/NMC:getWANStatus","POST",'{"parameters":{}}',null,$headers,true);
  64. echo $response;
  65. break;
  66.  
  67. case 'phonestate':
  68. $response = httpQuery("http://".$myhost."/sysbus/VoiceService/VoiceApplication:listTrunks","POST",'{"parameters":{}}',null,$headers,true);
  69. echo $response;
  70. break;
  71.  
  72. case 'tvstate':
  73. $response = httpQuery("http://".$myhost."/sysbus/NMC/OrangeTV:getIPTVStatus","POST",'{"parameters":{}}',null,$headers,true);
  74. echo $response;
  75. break;
  76.  
  77. case 'hosts':
  78. $response = httpQuery("http://".$myhost."/sysbus/Hosts:getDevices","POST",'{"parameters":{}}',null,$headers,true);
  79. echo $response;
  80. break;
  81.  
  82. case 'reboot':
  83. $response = httpQuery("http://".$myhost."/sysbus/NMC:reboot","POST",'{"parameters":{}}',null,$headers,true);
  84. echo $response;
  85. break;
  86.  
  87. case 'wifion':
  88. $response = httpQuery("http://".$myhost."/sysbus/NMC/Wifi:set","POST",'{"parameters":{"Enable":true,"Status":true}}',null,$headers,true);
  89. echo $response;
  90. break;
  91.  
  92. case 'wifioff':
  93. $response = httpQuery("http://".$myhost."/sysbus/NMC/Wifi:set","POST",'{"parameters":{"Enable":false,"Status":false}}',null,$headers,true);
  94. echo $response;
  95. break;
  96.  
  97. case 'mibs':
  98. $response = httpQuery("http://".$myhost."/sysbus/NeMo/Intf/data:getMIBs","POST",'{"parameters":{}}',null,$headers,true);
  99. echo $response;
  100. break;
  101.  
  102. case 'macoff':
  103. $response = httpQuery("http://".$myhost."/sysbus/NeMo/Intf/wl0:setWLANConfig","POST",'{"parameters":{"mibs":{"wlanvap":{"wl0":{"MACFiltering":{"Mode":"Off"},"WPS":{"Enable":false}}}}}}',null,$headers,true);
  104. echo $response;
  105. break;
  106.  
  107. case 'macon':
  108. $response = httpQuery("http://".$myhost."/sysbus/NeMo/Intf/wl0:setWLANConfig","POST",'{"parameters":{"mibs":{"wlanvap":{"wl0":{"MACFiltering":{"Mode":"WhiteList"}}}}}}',null,$headers,true);
  109. echo $response;
  110. break;
  111.  
  112. case 'dslinfo':
  113. $response = httpQuery("http://".$myhost."/sysbus/NeMo/Intf/data:getMIBs","POST",'{"parameters":{"mibs":"dsl","flag":"","traverse":"down"}}',null,$headers,true);
  114. echo $response;
  115. break;
  116.  
  117. default:
  118. $result = '{"result":"Aucune action definie"}';
  119. echo $result;
  120. break;
  121. }
  122.  
  123. /*
  124. echo "<xmp>";
  125. var_dump($json);
  126. echo "</xmp>";
  127. */
  128.  
  129. //logout
  130. $response = httpQuery("http://".$myhost."/logout","POST",null,null,true);
  131.  
  132. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement