Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. function getFormDiffPath($FormName, &$files)
  2. {
  3. $FormName = str_replace('\\','/',$FormName);
  4. $a = explode('.d/', $FormName);
  5. $c = count($a);
  6. while($c > 1)
  7. {
  8. $c--;
  9. $l = explode('/', $a[$c]);
  10. $f = explode('/', $a[$c - 1]);
  11. $bool = true;
  12. $res = array();
  13. for($li = 0, $cl = count($l); $li < $cl; $li++)
  14. {
  15. if(!isset($f[$li]) || $f[$li] != $l[$li] || !$bool)
  16. {
  17. $res[] = $l[$li];
  18. $bool = false;
  19. }
  20. }
  21. $a[$c] = implode('/', $res);
  22. }
  23. $FormName = implode('.d/', $a);
  24. $path = '';
  25. if(is_dir($d = dirname($_SERVER["SCRIPT_FILENAME"]) . get_option('Forms') . $FormName . '.d/'))
  26. {
  27. $path = $d;
  28. if($dirh = @opendir($path))
  29. {
  30. while(($file = readdir($dirh)) !== false)
  31. {
  32. $pi = pathinfo($path . $file);
  33. if(is_dir($path . $file . '/') || $pi['extension'] != 'dfrm')
  34. continue;
  35. //Для замены если есть в UserForms
  36. $files[$file] = $path . $file;
  37. }
  38. closedir($dirh);
  39. }
  40. }
  41.  
  42. if(is_dir($d = dirname($_SERVER["SCRIPT_FILENAME"]) . getUserForms() . $FormName . '.d/'))
  43. {
  44. $path = $d;
  45. if($dirh = @opendir($path))
  46. {
  47. while(($file = readdir($dirh)) !== false)
  48. {
  49. $pi = pathinfo($path . $file);
  50. if(is_dir($path . $file . '/') || $pi['extension'] != 'dfrm')
  51. continue;
  52. //Заменяем если есть в базовом
  53. $files[$file] = $path . $file;
  54. }
  55. closedir($dirh);
  56. }
  57. }
  58. return $path;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement