Пример #1
0
 function wpci_parse_path($path = array(), $params = array(), $use_context = TRUE)
 {
     global $RTR;
     // dump_code(array('path' => $path, 'params' => $params, 'use_context' => $use_context));
     if (!is_array($path)) {
         // detect protocol
         $protocol = array();
         $regex = '^((ci|do|front|frontend|back|backend|admin)?((\\+|\\-)?(s|secure|ssl))?://)?(\\.\\./)?';
         preg_match("#{$regex}#i", $path, $protocol);
         $path = preg_replace("#{$regex}#i", '', $path);
         // reverse the array to allow for a varying quantity of path specifiers
         $params_in_url = array();
         $src = array_reverse(split('\\/', $path));
         // first, while there are more than three elements in the path, pull out parameter values
         while (count($src) > 3) {
             array_unshift($params_in_url, array_shift($src));
         }
         $path = array();
         $path['params'] = $params_in_url;
         if (isset($src[0])) {
             $path['action'] = $src[0];
         }
         if (isset($src[1])) {
             $path['controller'] = $src[1];
         }
         if (isset($src[2])) {
             $path['application'] = $src[2];
         }
         if (wpci_get_ssl_enabled() != TRUE) {
             $path['secure'] = FALSE;
         } else {
             $path['secure'] = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
         }
         // dump_code($path);
         if (count($protocol)) {
             //dump_code($protocol);
             $context = isset($protocol[2]) ? $protocol[2] : null;
             $secure = isset($protocol[4]) ? $protocol[4] : null;
             // override contextual security setting
             if (wpci_get_ssl_enabled() == TRUE) {
                 if ($secure == '-') {
                     $path['secure'] = FALSE;
                 } else {
                     if ($secure == '+' || isset($protocol[5]) && $protocol[5]) {
                         $path['secure'] = TRUE;
                     }
                 }
             }
             // context?
             if ($context == 'ci' || $context == 'do' || $context == 'go' || $context == 'front') {
                 $path['context'] = 'front';
             } else {
                 if ($context == 'back' || $context == 'backend' || $context == 'admin') {
                     $path['context'] = 'back';
                 } else {
                     $path['context'] = is_admin() ? 'back' : 'front';
                 }
             }
             // absolute
             $path['absolute'] = $path['secure'] == TRUE || (isset($protocol[6]) && $protocol[6] ? FALSE : TRUE);
         }
     }
     // contextual defaults, if requested
     if ($use_context && $RTR) {
         $path = array_merge(array('application' => $RTR->fetch_app(), 'controller' => $RTR->fetch_class(), 'action' => $RTR->fetch_method(), 'directory' => $RTR->fetch_directory()), $path);
     }
     // dump_code($path);
     // other defaults
     $path = array_merge(array('absolute' => TRUE, 'params' => array(), 'context' => 'front'), $path);
     // merge parameters specified in $path with $params and save in $path
     if (!is_array($path['params'])) {
         $path['params'] = array($path['params']);
     }
     $path['params'] = array_merge($path['params'], $params);
     // sometimes $directory gets f****d up... don't know why...
     $path['directory'] = preg_replace("#\\/\\/#", "/", $path['directory']);
     // by default, directory needs to be a single slash
     if (!$path['directory']) {
         $path['directory'] = '/';
     }
     //dump_code($path);
     return $path;
 }
Пример #2
0
?>
						</td>
					</tr>
					<tr>
						<th class="row">Gateway Slug</th>
						<td>
							<?php 
echo form_input(array('name' => 'slug', 'value' => wpci_get_slug(), 'class' => 'regular-text'));
?>
						</td>
					</tr>
					<tr>
						<th class="row">SSL Support</th>
						<td>
							<?php 
echo form_dropdown('ssl_enabled', array('' => 'Disabled&nbsp;&nbsp;', 1 => 'Enabled'), wpci_get_ssl_enabled());
?>
						</td>
					</tr>
				</table>
			</div>
			<div id="debugging">
				<table class="form-table">
					<tr>
						<th class="row">Application Debugging</th>
						<td>
							<?php 
echo form_dropdown('application_debugging_enabled', array('' => 'Disabled&nbsp;&nbsp;', 1 => 'Enabled'), wpci_get_application_debugging_enabled());
?>
						</td>
					</tr>