Debug.class.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. class Debug{
  3. public static function loadAll(){
  4. $debugs = array();
  5. $debugs['command'] = (object) array('label'=>'Test de commande serveur','execute'=>
  6. function(){
  7. echo 'Commande lancée avec l\'utilisateur : '.get_current_user().PHP_EOL;
  8. echo 'Test ls -l (non silencieux)'.PHP_EOL;
  9. echo System::command('ls -ls');
  10. echo 'Test ls -l (silencieux)'.PHP_EOL;
  11. echo System::commandSilent('ls -ls');
  12. echo 'Get system infos'.PHP_EOL;
  13. print_r(System::getInfos());
  14. echo 'Done';
  15. });
  16. $debugs['connect'] = (object) array('label'=>'Test de connexion','execute'=>
  17. function(){
  18. $client = new Client;
  19. echo 'Connexion'.PHP_EOL;
  20. $client->connect();
  21. echo 'Connexion réussie'.PHP_EOL;
  22. $client->disconnect();
  23. echo 'Déconnexion';
  24. });
  25. $debugs['talk'] = (object) array('label'=>"Test de parole",'execute'=>
  26. function(){
  27. $client = new Client;
  28. echo 'Connexion'.PHP_EOL;
  29. $client->connect();
  30. $text = "Bonjour, je suis YANA, omnisciente, omnipotente. Je suis l'alpha et l'omega, le Yin et le Yang, la vie et la mort.";
  31. echo 'Envois du texte :'.$text.PHP_EOL;
  32. echo $client->talk($text).PHP_EOL;
  33. echo 'Parole envoyée'.PHP_EOL;
  34. $client->disconnect();
  35. echo 'Déconnexion';
  36. });
  37. $debugs['command'] = (object) array('label'=>"Test de commande",'execute'=>
  38. function(){
  39. $client = new Client;
  40. echo 'Connexion'.PHP_EOL;
  41. $client->connect();
  42. $command = "ls -l";
  43. echo 'Envois de la commande :'.$command.PHP_EOL;
  44. echo $client->execute($command).PHP_EOL;
  45. echo 'commande envoyée'.PHP_EOL;
  46. $client->disconnect();
  47. echo 'Déconnexion';
  48. });
  49. $debugs['others'] = (object) array('label'=>'Test de son, image, execution, emotion','execute'=>
  50. function(){
  51. $client = new Client;
  52. echo 'Connexion'.PHP_EOL;
  53. $client->connect();
  54. echo 'Envois son :'.PHP_EOL;
  55. echo $client->sound('C:\Users\Idleman\Music\Musique\Kalimba.mp3').PHP_EOL;
  56. echo 'Son envoyé'.PHP_EOL;
  57. echo 'Envois image :'.PHP_EOL;
  58. echo $client->image('http://blog.idleman.fr/wp-content/themes/twentytwelve/idleblog%20logo.png').PHP_EOL;
  59. echo 'image envoyée'.PHP_EOL;
  60. echo 'Envois commande shell :'.PHP_EOL;
  61. echo $client->execute('explorer').PHP_EOL;
  62. echo 'Commande envoyée'.PHP_EOL;
  63. echo 'Envois émotion :'.PHP_EOL;
  64. echo $client->emotion('angry').PHP_EOL;
  65. echo 'Emotion envoyée'.PHP_EOL;
  66. $client->disconnect();
  67. echo 'Déconnexion';
  68. });
  69. $debugs['commands'] = (object) array('label'=>'Récupération des commandes (GET_SPEECH_COMMANDS via socket)','execute'=>
  70. function(){
  71. global $myUser;
  72. $client = new Client;
  73. echo 'Connexion'.PHP_EOL;
  74. $client->connect();
  75. $auth = array(
  76. "action"=>"CLIENT_INFOS",
  77. "version"=>"2","type"=>"ear",
  78. "location"=>"moon",
  79. "token"=>$myUser->getToken()
  80. );
  81. echo 'Authentification via : '.json_encode($auth).PHP_EOL;
  82. $client->send($auth);
  83. $cmds = array("action"=>"GET_SPEECH_COMMANDS");
  84. echo 'Ordre de récuperation des commandes via : '.json_encode($cmds).PHP_EOL;
  85. echo PHP_EOL.'==================================== Réponse ================================='.PHP_EOL.PHP_EOL;
  86. echo $client->send($cmds,true);
  87. $client->disconnect();
  88. echo 'Déconnexion';
  89. });
  90. $debugs['clients'] = (object) array('label'=>'Récupération des clients connectés (GET_CONNECTED_CLIENTS via socket)','execute'=>
  91. function(){
  92. global $myUser;
  93. $client = new Client;
  94. echo 'Connexion'.PHP_EOL;
  95. $client->connect();
  96. $auth = array(
  97. "action"=>"CLIENT_INFOS",
  98. "version"=>"2","type"=>"face",
  99. "location"=>"moon",
  100. "token"=>$myUser->getToken()
  101. );
  102. echo 'Authentification via : '.json_encode($auth).PHP_EOL;
  103. $client->send($auth);
  104. $cmds = array("action"=>"GET_CONNECTED_CLIENTS");
  105. echo 'Ordre de récuperation des commandes via : '.json_encode($cmds).PHP_EOL;
  106. echo PHP_EOL.'==================================== Réponse ================================='.PHP_EOL.PHP_EOL;
  107. echo $client->send($cmds,true).PHP_EOL;;
  108. $client->disconnect();
  109. echo 'Déconnexion';
  110. });
  111. return $debugs;
  112. }
  113. }
  114. ?>