Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <?php
  2.  
  3. //loads api functions
  4. require "../api.php";
  5.  
  6. //defines location of export files
  7. $fileLocation = "C:\Program Files (x86)\Zend\Apache2\htdocs\analyticshumanly\data\bears.txt";
  8.  
  9. //defines adminhost
  10. $adminhost = "cognosdemo";
  11.  
  12. //defines TM1 server
  13. $server = "api";
  14.  
  15. //defines username
  16. $user = "admin";
  17.  
  18. //defines password
  19. $password = "apple";
  20.  
  21. //gets server method issued by client
  22. $method = $_SERVER['REQUEST_METHOD'];
  23.  
  24.  
  25. //claer file
  26. clearFile($fileLocation);
  27.  
  28. //execute request
  29. executeRequest($method, $fileLocation, $error, $adminhost, $server, $process, $user, $password);
  30.  
  31. /**
  32. *
  33. * Clears file before export
  34. *
  35. * @param $fileLocation location of file with exported data
  36. */
  37.  
  38. function clearFile($fileLocation){
  39.     file_put_contents($fileLocation,"");
  40. }
  41.  
  42. /**
  43. *
  44. * Depending on REQUEST_METHOD function executes different processes
  45. *
  46. * @param $method HTTP method issed by client
  47. */
  48.  
  49. function executeRequest($method, $fileLocation, $error, $adminhost, $server, $process, $user, $password){
  50.     switch ($method){
  51.         case "GET":
  52.             $process = "exportCubeBears";
  53.             $message = executeProcess($adminhost, $server, $process, $user, $password);
  54.                 //issue message if any error occured
  55.             if ($message!=0){
  56.                 echo $error[$message];
  57.             }
  58.             else {
  59.                 $data = getData($fileLocation);
  60.                 echo $data;
  61.             }  
  62.             break;
  63.         }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement