Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix install.php #954
It's not too important on this one as I wrote install.php so pretty confident no copyright issues with the changes, however for other PRs it might be needed so easier to just do it now :)
On this PR, if you can push a new commit that removes ?> from the end of config.php that would be good, we've dropped this from all other places now as it can lead to issues if left in.
I'm running the code on FreeBSD 10.1, librenms is installed in /usr/local/www/librenms
$_SERVER['DOCUMENT_ROOT'] = /usr/local/www/librenms/html
After running $install_dir = implode('/',$cur_dir); $install_dir should be /usr/local/www/librenms and not /usr/local/www, which is I why I commented out the second $install_dir = array_pop($cur_dir); line
Should $_SERVER['DOCUMENT_ROOT'] be equal to a sub folder in html? or should install_dir point to /usr/local/www/ in the end?
The implode creates the array and then pops two elements off the end, the first being blank (/usr/local/www/librenms/ ends with BLANK usr local www librenms html BLANK) the second being html so you end up with /usr/local/www/librenms when it's imploded back.
It's a hack to get the true install location, if you leave it in it should be all ok.
Awesome, thanks mate.
The issue was simpler than I expected, for you there is a "/" at the end of $_SERVER['DOCUMENT_ROOT'], but for me there wasn't. I'm not a PHP guy and this didn't register for me. When I changed the following setting in nginx
fastcgi_param DOCUMENT_ROOT $document_root;
$_SERVER['DOCUMENT_ROOT'] changed and now it ends with a "/" and removing the comment works the same way it does for you, no change needed. I will remove the commit and add the code again
Nearly there :)
So now when the file creation fails the user isn't shown any errors or anything. This patch will fix that for now, needs tidying up but we can do that later:
If you apply that and commit the update it should be good to go. One comment on how you've done the PR is that you're working in your master branch which isn't really the best way. We can merge this time around but it would be worth you having a look at http://docs.librenms.org/Developing/Using-Git/ to get a better idea of how to work using git locally before submitting a PR :)