Accessing An External Programm

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

If The Host Doesn't Run php In Safe Mode Can I Then Use shell_exec or exec()
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

There are other ways to disable the exec functions.
Try

Code: Select all

$fns = array('shell_exec', 'exec');
foreach($fns as $f) {
	echo $f, function_exists($f) ? ' exists':' does not exist', "<br />\n";
}
echo 'disabled functions: ', ini_get('disable_functions'), "<br />\n";
echo 'disabled classes: ', ini_get('disable_classes'), "<br />\n";
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

No no
I Dont Want To Disable It

I Wanna Know If I Am Hosted In A Shared Hosted Linux Server Where Safe Mode Is Turned Off and I am Alowed To Use program Execution Functions In php Then -->


OK Wrote In Linux I Have To Define The Full Path To The out File
OK On 4th Page wrote: I tested it and it can run but the PHP code should like that:

Code: Select all

$output = shell_exec('/full/path/to/executable/pass_arg.out arg1 arg2'); 
echo $output;

In Shared Hosting What Would Be The Full Path ?? Is It like http://www.mysitename.com/somedir/paaa_arg.out ??
or Some Thing Else And In Shared Hosting How Can I Know The Actual Full Path Where I am Hosted Are There Any Function To Get It ??

If Its then How To Use That Function

If Its Not Possible Are there Another program execution Functions in php By which
I can Execute pass_arg.out file Without Specifing The Full Path Of That File


Are There Any Other functions In php That Doesn't requir The Full Path To The Binary out File Are There Any function That Can work With The short Path
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

neel_basu wrote:No no
I Dont Want To Disable It
:?: I know
Ok, let's try again:
If The Host Doesn't Run php In Safe Mode Can I Then Use shell_exec or exec()
MaYbE. mAyBe NoT. nOt RuNnInG iN sAfE mOdE dOeS nOt GuArAnTeE eXeC() oR sHeLl_ExEc() ArE aVaIlAbLe
TrY tHe ScRiPt. It WiLl TeLl YoU wEtHeR tHe FuNcTiOnS aRe AvAiLaBlE oR nOt
neel_basu wrote:In Shared Hosting What Would Be The Full Path ?? Is It like http://www.mysitename.com/somedir/paaa_arg.out ??
or Some Thing Else And In Shared Hosting How Can I Know The Actual Full Path Where I am Hosted Are There Any Function To Get It ??
You haven't tried what ok suggested, have you?
neel_basu wrote:If Its Not Possible Are there Another program execution Functions in php By which
I can Execute pass_arg.out file Without Specifing The Full Path Of That File
You can use a relative path, see http://en.wikipedia.org/wiki/Path_%28computing%29
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Then Can I Mak Sure About It That

Code: Select all

$output = shell_exec('/full/path/to/executable/pass_arg.out arg1 arg2');
would do The Same Job As

Code: Select all

$output = shell_exec('pass_arg.out arg1 arg2');
If Both of Them Are in The same Directory
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Even though shared host are not running in safe mode, they might sometime don't allow to use certain functions which might be harmful for the shared server.


Suppose if php.ini contains the following options :

Code: Select all

disable_functions = exec, shell_exec
You'll not be able to use these functions.
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

I suggest you to convert the C program to a PHP program. If you don't know how to do it, post here the code of the C program and we will help you.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Actually I am Trying To Build A Module For Encryption

And If Its A Php File Someone May Decrypt it Creating The Reverse Code Of That
php file

Thats Why I Am Trying To Build It as A Binary File
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

There's still no need for an "external" program for that. Chances are you'd rather increase the threat level. And as mentioned: It's unlikely your method beats those of standard encryption modules e.g. provided by mcrypt. You might come up with a fabulous new way of encrypting data one day but as a beginner ....
Really, there's no point to it and you'll learn as much or even more from using a given crypto lib as from trying to build some encoderish thingeling ;)
Post Reply