From 988e67ca92957bbce884a80c075e813093b851d8 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 6 Jun 2015 11:35:57 -0400 Subject: [PATCH] Fix basePath in APIExplorer examples --- CRM/Admin/Page/APIExplorer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CRM/Admin/Page/APIExplorer.php b/CRM/Admin/Page/APIExplorer.php index 50bd2d0124..cef15f8ad8 100644 --- a/CRM/Admin/Page/APIExplorer.php +++ b/CRM/Admin/Page/APIExplorer.php @@ -52,7 +52,7 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { // List example directories global $civicrm_root; $examples = array(); - foreach (scandir($civicrm_root . 'api/v3/examples') as $item) { + foreach (scandir(CRM_Utils_file::addTrailingSlash($civicrm_root, '/') . 'api/v3/examples') as $item) { if ($item && strpos($item, '.') === FALSE) { $examples[] = $item; } @@ -77,9 +77,10 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { */ public static function getExampleFile() { global $civicrm_root; + $basePath = CRM_Utils_file::addTrailingSlash($civicrm_root, '/'); if (!empty($_GET['entity']) && strpos($_GET['entity'], '.') === FALSE) { $examples = array(); - foreach (scandir($civicrm_root . 'api/v3/examples/' . $_GET['entity']) as $item) { + foreach (scandir($basePath . 'api/v3/examples/' . $_GET['entity']) as $item) { $item = str_replace('.php', '', $item); if ($item && strpos($item, '.') === FALSE) { $examples[] = array('key' => $item, 'value' => $item); @@ -88,7 +89,7 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { CRM_Utils_JSON::output($examples); } if (!empty($_GET['file']) && strpos($_GET['file'], '.') === FALSE) { - $fileName = $civicrm_root . 'api/v3/examples/' . $_GET['file'] . '.php'; + $fileName = $basePath . 'api/v3/examples/' . $_GET['file'] . '.php'; if (file_exists($fileName)) { echo file_get_contents($fileName); } -- 2.25.1