Skip to content

Commit

Permalink
Added ability to run pages from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
AliasIO committed Apr 14, 2013
1 parent 74cabf3 commit 156ea9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009 ElbertF http:https://swiftlet.org
Copyright (c) 2009 Elbert F http:https://swiftlet.org

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
13 changes: 10 additions & 3 deletions Swiftlet/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ public function run()
// Determine the client-side path to root
if ( !empty($_SERVER['REQUEST_URI']) ) {
$this->rootPath = preg_replace('/(index\.php)?(\?.*)?$/', '', $_SERVER['REQUEST_URI']);
}

if ( !empty($_GET['q']) ) {
$this->rootPath = preg_replace('/' . preg_quote(rawurlencode($_GET['q']), '/') . '$/', '', $this->rootPath);
}
// Run from command line, e.g. "php index.php -q index"
$opt = getopt('q:');

if ( isset($opt['q']) ) {
$_GET['q'] = $opt['q'];
}

if ( !empty($_GET['q']) ) {
$this->rootPath = preg_replace('/' . preg_quote(rawurlencode($_GET['q']), '/') . '$/', '', $this->rootPath);
}

// Extract controller name, view name, action name and arguments from URL
Expand Down

0 comments on commit 156ea9f

Please sign in to comment.