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.

General Questions /

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

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

EXECUTING INDEPENDEN PHP SCRIPT


Reply


2 Posts   636 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, 5513 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/