Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b9781c5

Browse files
cleanup required
1 parent 9e5af8e commit b9781c5

File tree

1 file changed

+100
-5
lines changed

1 file changed

+100
-5
lines changed

‎src/router.class.php‎

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
error_reporting(E_ALL);
23
$headers = array('Accept', 'Accept-CH', 'Accept-Charset', 'Accept-Datetime', 'Accept-Encoding', 'Accept-Ext', 'Accept-Features', 'Accept-Language', 'Accept-Params', 'Accept-Ranges',
34
'Access-Control-Allow-Credentials', 'Access-Control-Allow-Headers', 'Access-Control-Allow-Methods', 'Access-Control-Allow-Origin', 'Access-Control-Expose-Headers',
45
'Access-Control-Max-Age', 'Access-Control-Request-Headers', 'Access-Control-Request-Method', 'Age', 'Allow', 'Alternates', 'Authentication-Info', 'Authorization', 'C-Ext',
@@ -395,6 +396,7 @@ function console_output()
395396
} else {
396397

397398
if (file_exists($uri_filepath) && !is_dir($uri_filepath)) {
399+
//if (is_file($uri_filepath)) {
398400

399401
$this->process_request();
400402

@@ -407,12 +409,12 @@ function console_output()
407409
//echo $this->script_filename.'<br />'.$_SERVER['SCRIPT_FILENAME'];
408410
//die();
409411

410-
if( in_array($this->getExt($this->script_filename), array("","php")) ){
412+
if (in_array($this->getExt($this->script_filename), array("","php"))) {
411413

412414
//return include($_SERVER['SCRIPT_FILENAME']);
413-
return include($_SERVER['DOCUMENT_ROOT'] .'/' . $this->indexPath);
415+
return include($_SERVER['DOCUMENT_ROOT'] .'/' . $this->indexPath);
414416

415-
}else{
417+
}else{
416418

417419
return include($this->script_filename);
418420

@@ -493,23 +495,116 @@ private function URIhasPHP()
493495

494496
}
495497

498+
function fix_path_info()
499+
{
500+
501+
$url = $_SERVER['REQUEST_URI'];
502+
503+
if (($url_no_q = strstr($url, '?', true)) !== FALSE) {
504+
$url = $url_no_q;
505+
}
506+
507+
508+
$path_info = isset($_SERVER['PHP_INFO']) ? $_SERVER['PHP_INFO'] : '/';
509+
$script_name = $_SERVER['SCRIPT_NAME'];
510+
$php_self = $_SERVER['PHP_SELF'];
511+
512+
if (($dot = strstr($url, '.')) !== FALSE) {
513+
514+
if (($ext = strstr($dot, '/', TRUE)) !== FALSE) {
515+
516+
$explode = explode('/', $dot);
517+
$path_info = '/' . $explode[1];
518+
$script_name = strstr($url, '.', TRUE) . rtrim($ext, '/');
519+
$php_self = substr($php_self, strlen($script_name)) . $script_name;
520+
$script_name = $php_self;
521+
522+
}
523+
524+
}
525+
526+
/* echo 'url:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $url . '<br />';
527+
echo 'path info:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $path_info . '<br />';
528+
echo 'php self:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $php_self . '<br />';
529+
echo 'script name&nbsp;&nbsp;&nbsp;' . $script_name;*/
530+
531+
if( isset($_SERVER['HTTP_L'])){
532+
$_SERVER['HTTP_CACHE_CONTROL'] = $_SERVER['HTTP_L'];
533+
unset($_SERVER['HTTP_L']);
534+
}
535+
536+
//$_SERVER['PHP_SELF'] = $php_self;
537+
538+
if (!isset($_SERVER['PHP_INFO']) && substr($_SERVER['REQUEST_URI'], -1, 1) !== '/' && $this->getExt($_SERVER['REQUEST_URI']) == "") {
539+
540+
$_SERVER['REQUEST_URI'] = $_SERVER['REQUEST_URI'] . '/';
541+
$_SERVER['PHP_SELF'] = $_SERVER['PHP_SELF'] .'/';
542+
543+
}
544+
545+
$_SERVER['ORIG_PHP_SELF'] = $_SERVER['PHP_SELF'];
546+
$_SERVER['ORIG_PATH_INFO'] = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : "";
547+
548+
//echo $_SERVER['SCRIPT_NAME'].'<br />';
549+
//echo '<pre>';
550+
//print_r($_SERVER);
551+
//$_SERVER['SCRIPT_NAME'] = $script_name; // drupal themes won't work with this on
552+
$_SERVER['PATH_INFO'] = $path_info;
553+
//echo $_SERVER['SCRIPT_NAME'].'<br />';
554+
555+
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
556+
557+
if( substr($_SERVER['PHP_SELF'], -1 , 1 ) == '/'){
558+
$_SERVER['PHP_SELF'] = substr($_SERVER['PHP_SELF'],0,-1);
559+
}
560+
561+
}
562+
496563
/**
497564
* Listen for requests
498565
* @return bool|mixed
499566
*/
500567
function listen()
501568
{
502569

570+
$this->fix_path_info();
503571
$this->init();
504572

505-
if ($this->URIhasPHP()) {
506573

507-
return FALSE;
574+
if (in_array($this->getExt($this->URI_no_query()), array("", "php"))) {
575+
576+
/**
577+
* Drupal file uploads
578+
*/
579+
580+
if ($this->URIhasPHP()) {
581+
582+
return FALSE;
583+
584+
}else{
585+
586+
/**
587+
* Wordpress wp-admin
588+
*/
589+
590+
if( $this->getExt($this->URI_no_query()) == "" ){
591+
592+
/**
593+
* Output hack fix
594+
*/
595+
header("Content-Length: -1");
596+
597+
return FALSE;
598+
599+
}
600+
601+
}
508602

509603
}
510604

511605
return $this->bootstrap();
512606

607+
513608
}
514609

515610
/**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /