Welcome Guest, Not a member yet? Register   Sign In
Call Function from a PHP-Script outside http-Root
#1

[eluser]grolle[/eluser]
Hi,

for CronJobs I got an PHP-Script which is on level above the http-Root (same level like the ci-system). Is ist possible to call a function from my codeigniter-application from this script?

Best regards ...
#2

[eluser]jblack199[/eluser]
Well for use with CI I couldn't tell ya 100%, however PHP in general in order to include a file that is above root, you need to not use a relative path.. ie: ../function.php but you need to use the full server path to the file...

include('/home/username/include.php');

now i'd think you can use 'include' in CI but I haven't tested that so I couldnt truly tell you but in stand-alone PHP thats how you would do it.
#3

[eluser]grolle[/eluser]
Hi,

I want to call a ci-function because it is much easier to send a mass-mail with ci than implement this with stand-alone PHP.

Best regards ...
#4

[eluser]jblack199[/eluser]
ahh.. well yeah you should be able to call a function of CI in your other script, i had it the other way around -- I thought you wanted to use a function in your cronjob.php in CI... but still you should be able to theoretically, being that the file is in above_server_root, a simple include might work since generally the include runs off the document_root path... but you might have to use the full server path for it as well.
#5

[eluser]grolle[/eluser]
Hi,

thanks, I have a try.

Best regards ...
#6

[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...l/cli.html
#7

[eluser]grolle[/eluser]
Hi,

thanks - you made my day. That looks really great! One last question left: My webhoster said, that I have to place the shebang(#!/usr/bin/php) in the first line of the script. Did I have to place it in the first line of the controller?

Best regards ...
#8

[eluser]jblack199[/eluser]
in the controller no, usually for a cronjob script some hosts system requires it.. so put it in your script that is above root.




Theme © iAndrew 2016 - Forum software by © MyBB