Ejemplo n.º 1
0
 /**
  * 构造函数
  */
 public function __construct()
 {
     if (sharePHP::get_mode() === 2) {
         $get = fliter($_SERVER['REQUEST_URI']);
         $class = sharePHP::get_class();
         $method = sharePHP::get_method();
         $i = strpos(fliter($_SERVER['REQUEST_URI']), $class . '/' . $method);
         $get = explode('/', substr($get, $i + strlen($class . '/' . $method) + 1));
         $flag = null;
         foreach ($get as $k => $g) {
             if ($flag === null) {
                 $GLOBALS['_GET'][$g] = '';
                 $flag = fliter($g);
             } else {
                 $GLOBALS['_GET'][$flag] = fliter($g);
                 $flag = null;
             }
         }
     }
 }
Ejemplo n.º 2
0
/**
 * 构造url
 * @param $class 类名
 * @param $method 方法名
 * @param $param 参数(a=1&b=2&c=3...)
 * @param $static 是否是静态地址
 */
function url($class = null, $method = null, $param = null, $static = true)
{
    $url = sharePHP::get_base_url();
    if ($class && $method) {
        if (sharePHP::get_mode() == 1) {
            $url .= '?action=' . $class . '.' . $method;
        } else {
            if (sharePHP::get_mode() == 2) {
                $url .= $class . '/' . $method . '/';
            } else {
                if ($static === true) {
                    $url .= 'html/' . $class . '/' . $method . '/';
                } else {
                    if (MODE == 1) {
                        $url .= '?action=' . $class . '.' . $method;
                    } else {
                        $url .= $class . '/' . $method . '/';
                    }
                }
            }
        }
    }
    if (!$param) {
        return $url;
    }
    $action = explode('&', $param);
    foreach ($action as $act) {
        if (sharePHP::get_mode() == 1) {
            $url .= '&' . $act;
        } else {
            if (sharePHP::get_mode() == 2) {
                $p = explode('=', $act);
                $url .= $p[0] . '/' . $p[1] . '/';
            } else {
                $p = explode('=', $act);
                if ($static === true) {
                    $url .= $p[1] . '.html';
                } else {
                    if (MODE == 1) {
                        $url .= '&' . $act;
                    } else {
                        $url .= $p[0] . '/' . $p[1] . '/';
                    }
                }
            }
        }
    }
    return $url;
}