These are chat archives for jbroadway/elefant

27th
Feb 2014
z31nf0rd
@z31nf0rd
Feb 27 2014 10:39
EDIT
If put it
```
if (preg_match ('|^/newadminpanel?/?|', $_SERVER['REQUEST_URI'])) {
    $_SERVER['REQUEST_URI'] = '/admin' . $_SERVER['REQUEST_URI'];
}
at bootstrap.php it cause error, otherwise I put it on index.php line 133 it work, but the problem is I still can't block access to /admin, when I block it via htaccess after I login from /newadminpanel head topbar not shown
Johnny Broadway
@jbroadway
Feb 27 2014 14:36
Here’s what I came up with for steps: https://gist.github.com/jbroadway/9251281
Woah, didn’t expect it to put the whole gist inline haha :P This will replace /admin with /newadminpanel, but still allow links like /admin/pages to function properly, so the toolbar bar should still work correctly.
z31nf0rd
@z31nf0rd
Feb 27 2014 14:49

I get this error

ErrorException: preg_replace(): No ending delimiter '^' found

preg_replace ("^/newadminpanel", "/admin", "/")

:-(

try to change with this

if (preg_match ('|^/newadminpanel?/?|', $_SERVER['REQUEST_URI'])) {
    $_SERVER['REQUEST_URI'] = '/admin' . $_SERVER['REQUEST_URI'];
}

it works

z31nf0rd
@z31nf0rd
Feb 27 2014 14:56
I'm sorry I don't use nginx server, instead I use apache, I try to block with htaccess but toolbar don't show :-(
Johnny Broadway
@jbroadway
Feb 27 2014 15:00
How about this in your Apache config?
Redirect 404 /admin
z31nf0rd
@z31nf0rd
Feb 27 2014 15:04
still same, toolbar don't show :-(
Johnny Broadway
@jbroadway
Feb 27 2014 15:05
Are you using the bootstrap.php from the gist or the other one?
z31nf0rd
@z31nf0rd
Feb 27 2014 15:08

my bootstrap.php only contain this

if (preg_match ('|^/newadminpanel?/?|', $_SERVER['REQUEST_URI'])) {
    $_SERVER['REQUEST_URI'] = '/admin' . $_SERVER['REQUEST_URI'];
}

if I use this

<?php

$_SERVER['REQUEST_URI'] = preg_replace (
    '^/newadminpanel',
    '/admin',
    $_SERVER['REQUEST_URI']
);

?>

I get error like this

ErrorException: preg_replace(): No ending delimiter '^' found

preg_replace ("^/newadminpanel", "/admin", "/")
Johnny Broadway
@jbroadway
Feb 27 2014 15:10
Ah, looks like I didn’t copy the finished bootstrap contents into the gist… oops. Here’s what worked for me:
<?php

$_SERVER['REQUEST_URI'] = preg_replace (
    '|^/newadminpanel|',
    '/admin',
    $_SERVER['REQUEST_URI']
);

?>
z31nf0rd
@z31nf0rd
Feb 27 2014 15:13
It's works but still top bar don't show when I make Redirect 404 /admin at htaccess
Johnny Broadway
@jbroadway
Feb 27 2014 15:14
Does the top bar show when you include the other steps, but not the Apache change?
z31nf0rd
@z31nf0rd
Feb 27 2014 15:15
Yes, only when I block /admin from apache top bar don't show
Johnny Broadway
@jbroadway
Feb 27 2014 15:17
How about this instead?
RedirectMatch 404 ^\/admin$
z31nf0rd
@z31nf0rd
Feb 27 2014 15:19
Yes it's work :-)
thank you very much :-)
Johnny Broadway
@jbroadway
Feb 27 2014 15:20
Awesome! :D
z31nf0rd
@z31nf0rd
Feb 27 2014 15:20
It's so kind of you :-)
Johnny Broadway
@jbroadway
Feb 27 2014 15:21
No problem, it also helps make the software better to think about challenges like these :)
z31nf0rd
@z31nf0rd
Feb 27 2014 15:28
also adding this RedirectMatch 404 ^\/admin/$ to prevent access /admin/ :-)
Johnny Broadway
@jbroadway
Feb 27 2014 15:31
Or even just this:
RedirectMatch 404 ^\/admin\/?$
z31nf0rd
@z31nf0rd
Feb 27 2014 15:32
yeah, It's better ! :-) thanks again :-)