atom-open-by-url.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env php
  2. <?php
  3. $scriptName = basename(__FILE__);
  4. if ($_SERVER['argc'] < 2) die("Usage: {$scriptName} url\n");
  5. if (empty($_SERVER['argv'][1])) die("Usage: {$scriptName} url\n");
  6. $url = $_SERVER['argv'][1];
  7. echo">>> DBG L." . __LINE__ . ": url: '{$url}'\n";
  8. // UrlAction_ProjektyProNetMediaZamZlec
  9. // https://biuro.pro-netmedia.pl/dev-pl-se/index.php?_route=UrlAction_ProjektyProNetMediaZamZlec&ID_PROJECT=50
  10. if (false === strpos($url, 'index.php')) die("Unrecognized url - no index.php\n");
  11. $query = parse_url($url, PHP_URL_QUERY);// only query string
  12. echo">>> query:"; print_r($query);echo"\n";
  13. $args = array(); parse_str($query, $args);
  14. echo">>> args:"; print_r($args);echo"\n";
  15. if (!empty($args['_route'])) {
  16. $route = $args['_route'];
  17. echo">>> DBG L." . __LINE__ . ": found route '{$route}'\n";
  18. $pathProject = dirname(__FILE__);
  19. $path = $pathProject . '/SE/se-lib/Route/' . implode('/', explode('_', $route)) . '.php';
  20. echo">>> DBG L." . __LINE__ . ": path '{$path}'\n";
  21. if (file_exists($path)) {
  22. echo">>> DBG L." . __LINE__ . ": found file '{$path}' for route '{$route}'\n";
  23. exec("cd {$pathProject}; atom {$path}");
  24. return;
  25. } else {
  26. $path = "{$pathProject}/SE/se-lib/Route/{$route}.php";
  27. if (file_exists($path)) {
  28. echo">>> DBG L." . __LINE__ . ": found file '{$path}' for route '{$route}'\n";
  29. exec("cd {$pathProject}; atom {$path}");
  30. return;
  31. }
  32. }
  33. die("Unrecognized url - cannot find class file for route '{$route}'\n");
  34. } else die("Unrecognized url - missing _route\n");
  35. exit;
  36. ?>