Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

EXECUTING INDEPENDEN PHP SCRIPT


Go to End


2 Posts   1075 Views

Avatar
servalman

Community Member, 211 Posts

15 March 2011 at 10:35pm

Hello

I have a php script updatescript.php in a folder code/mycode/ updatescript.php

I solved the problem of accessing the script py putting a .htaccess file in the folder with :

<Files updatescript.php>
allow from all
</Files>

It is working and I have access to it but my problem now is that it seems that I can not execute the script .

Is there some other instrcution/permission I have to give for it to work ?

Thank you

Avatar
Willr

Forum Moderator, 5523 Posts

16 March 2011 at 6:04pm

Are you executing it via the web interface or cli? The default .htaccess will route any requests to php files through sapphire/main.php so that users can not simply download all your files. I would recommend writing a simple SilverStripe controller to wrap your script. Something like

<?php

class MySpecialController extends Controller {

function index() {
require_once '/path/to/file.php';

run_something();
}
}

Then you can hit the URL site.com/MySpecialController/