1) { $_left_p = -1 * (count ($rel_path) + ($_remaining - 1)); $rel_path = array_pad ($rel_path, $_left_p, ".."); break; // Stop now, no need to go any further. } else // Else, set as the same directory `./[0]`. { $rel_path[0] = "./" . $rel_path[0]; break; // Stop now. } } } return implode ("/", $rel_path); } /** * Creates a directory Junction in Windows. * * @package s2Member\Utilities * @since 111013 * * @param string $jctn Directory location of the Junction (i.e., the link). * @param string $target Target directory that this Junction will connect to. * @return bool True if created successfully, or already exists, else false. */ public static function create_win_jctn ($jctn = FALSE, $target = FALSE) { if ($jctn && is_string ($jctn) && $target && is_string ($target) && stripos (PHP_OS, "win") === 0) { if (is_dir ($jctn)) // Does it already exist? If so return now. return true; // Return now to save extra processing time below. else if ( /* Possible? */function_exists ("shell_exec") && ($esa = "escapeshellarg")) { @shell_exec ("mklink /J " . $esa ($jctn) . " " . $esa ($target)); clearstatcache (); // Clear ``stat()`` cache now. if (is_dir ($jctn)) // Created successfully? return true; } } return false; // Else return false. } /** * Get the system's temporary directory. * * @package s2Member\Utilities * @since 111017 * * @param string $fallback Defaults to true. If true, fallback on WordPress routine if not available, or if not writable. * @return str|bool Full string path to a writable temp directory, else false on failure. */ public static function get_temp_dir ($fallback = TRUE) { $temp_dir = (($temp_dir = realpath (sys_get_temp_dir ())) && is_writable ($temp_dir)) ? $temp_dir : false; $temp_dir = (!$temp_dir && $fallback && ($wp_temp_dir = realpath (get_temp_dir ())) && is_writable ($wp_temp_dir)) ? $wp_temp_dir : $temp_dir; return ($temp_dir) ? c_ws_plugin__s2member_utils_dirs::n_dir_seps ($temp_dir) : false; } } }