Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How Do You Do TCL Exec Command On PHP Script That Uses User Input?


The TCL command I am using will do a command-line action on a PHP
script:

set cannotRunPHP [catch {
eval "exec php -q $root/scripts/info/php/info.php"
} errMsg]

I have to do it this way as both the TCL script and the PHP script run
as CLI. However, "info.php" requires user input to run; this causes
the TCL script calling the PHP script to hose up and die.

Is there a way I can do this so that the TCL script can call the PHP
script without any problems? Is there an alternate way of calling the
PHP script other than using exec were that to solve this issue?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Better Exec() Command
I work in a network support office which uses a web form to receive
network related problem reports from our end users. The web server is
IIS 5.0 on win2k server, and we use PHP and MySQL to handle the form
and tracking.

I'd like this setup to launch an mp3 player on the web server when a
problem report is sent in. I've tried exec("little mp3 player i
wrote"), but there are two issues with it:

1) I think the mp3 player runs as the user who sends in the report.
If the report is sent from the web server itself, everything works
fine. Otherwise, the mp3 player runs in the background and can't be
shut off.

2) The script waits for the mp3 player to be closed to finish.

I'm guessing there's a different command that will solve problem 2,
but I'm stumped on problem 1. It's more of an IIS/windows issue,
probably,

Problem With Exec Command
I'm having a problem with the exec command. Well, my application has a text to speech converter.it is working fine when i try to run it through command prompt. it is successfully converting the text file to audio file(mp3). but when i'm trying to convert through my application using exec command it
is unable to execute the command.

can you please tell me the reason why it couldn't. are there
any permission issues as far as exec concern.

i tested it on the live server using remote desktop connection.

My Server Configuration is:

OS : windows 2003 standard edition 64 bit.
web server: iis6
php version: 5.1.4

safe_mode is off in the php.ini file
given write permissions to the site (the converted file will be
created in the site folder only)

Just One Line ! (exec Command)
I would most like to just get the first line from exec result. The last line just isn't what I want. When I use passthru it doesn't allow me to store the results in a variable, so that's no good.

Exec() Command Not Functioning In Php
I have the following HTML code, which executes a PHP script.
==================================================
<!--HTML CODE-->
<html><head><title>Vulneraility Scan</title></head>

<body><form method="POST" action="n2.php">
Host<input name="address" type="text" value="IP Address">
<input type="submit" name="Submit" value="SCAN">
</form></body>
</html>
<!--END OF HTML CODE-->
==================================================
The PHP script is
==================================================
<?php
$ip = $_POST['address'];
$com2="echo $ip > targets.txt";
exec($com2);

$com3="rm -rf
results.html";
exec($com3);
echo "<br>This May Take Time";
$com4="nessus -q -T html localhost 1241 j1 abcd targets.txt
results.html";
exec($com4);
echo "<br>Finished";
?>
==================================================
I only see "This May Take Time " and "Finished" words on the screen,
the exec() commands do not execute.

Simple Php Exec Command
I have made a php script that at first loads rtorrent in a bash file which starts and boots up a torrent. Well for some reason it worked on my Gentoox (xbox linux) but not any of the other linux os I tried from Fedora core 4 and centos 3. Now I moved on to ctorrent and I run the same thing and it loads the torrent from what I see on the tracker but it does not upload. What is crazy is if I use ssh and run the bash script it boots up fine. let me show you what I'm saying. Code:

PHP Command Line Called Via Exec();
If I enter the following at the command line, I
successfully get an email sent to the correct name/email:

php /var/www/html/admin/adminscripts/welcome-cli.php
'Me' 'me@me.net' ....

Folder Zip - Execute Unix Zip Command Exec()
1.Any one knows How to Zip the folder using php.

2.How execute unix zip Command exec() function.

Is There Any Command That Allow The User To Print To Printer?
Is there any specific command in PHP that will allow the user to print the web page when the user click on the button?(beside go to File->Print)

User Input...
I have a form with a field that expects user to input HTML tags. I know I have to use htmlspecialchars for that input but what if the user inputs PHP code? I've looked at the help file and I can only find strip_tags which removes both PHP and HTML tags.

If a user wants to crash/corrupt/hack into your site by entering PHP code, what kind of things can he type? Must he include PHP tags to work? If he must use PHP tags, I could just write a function to remove only the PHP tags and not the HTML tags.

User Input?
Is there a way to get user input from a php script that doesn't have to do
with html? I would like to ask the user(me) to input a directory(preferably
in a gui way such as a folder selection dialog) to do some work with. Is
this possible when running the script directly on my comp(not off a
server(remote or local))?

The script is a management thing that I'd like to create to help generate
some html code. Essentially I want it to scan a dir(but don't want to hard
code it) and have it generate a list of links for the files in that
dir(which are images). Maybe even asking for a description for each.

Even if it was a little shell program to change the directory(sorta like
dos) would be much better than having to enter in the directory name by
hand.

Php User Input
When running PHP as a binary, is there a way to ask for user input?

Verifying User Input
I want to be able to search through a string that gets filled into my form. Make sure there are no quotes, semicolons and that kind of thing, that will mess up my database query. PHP Code:

What To Strip From User Input:
I recently suffered massive bot attacks against my contact page.
Someone sent me over 350 e-mails from my form in less than a couple of
hours. As this form only sends e-mail to an address dedicated for
this purpose, this isn't more than an inconvenience. In re-writing it,
I decided to write better stripslash and strip_tags functions of my
own. I have the function stripping out left and right angle brackets,
and forward and back slashes. I replace these with blanks (I am the
only one that views these e-mails and I think I can figure out what
was meant). That should break most script and malicious html tags.

What else should I watch for and strip? I thought it might be wise to
replace "=" signs with blanks. Should I worry about words like
"query" or "fopen"?

Part of my solution to preventing bot attacks against my form is to
force manual input by varying the name="" values. I have eighteen
different possibilities for each field on the form. I choose which to
use randomly. I check each possibility when processing to see if it
is set and send posters to a 404 page if they post to the wrong or all
possible variables. I also include a random string of 5 digits as an
authorization code in a hidden field. I use mysql database to let the
processing page know what variables and authorization code to expect,
associated with the poster's ip. Use the wrong authorization code and
you go to the 404 page. If your ip doesn't show up on in the
database, you get a "404 page not found." I delete records from the
database after processing, including old, unused entries where someone
left without completely filling out the form. Does anyone see any
reason that won't work to thwart the bots?

User Input Validation
I am intending to make a form on a page, on pushing submit the forms gets posted  onto itself so that it checks for empty fields and prompts user to get all fields filled, BUT the filled value should stay, I did this easily on ASP, but could not figure out in PHP. Code:

User Input Filtering
I have a comments system. In this comment system, people can enter certain strings, and it will break my page layout. Such as repeated characters with no spaces. It will just blow the table way out of proportion and completely ruin my layout. How can I break their input up if such a thing happens? Also, how can you number an array of data that is being withdrawn from the database DESC? Such as..

Quote1. itemnumber1
2. itemnumber2
3. itemnumber3
4. itemnumber4

Checking User Input
I want to check to see if there's only letters and numbers in a field, how would I go about doing this?

Filtering User Input...
I want to take text that a user inputs and store it into a variable.  That's the easy part.
I have and array of 30 elements that I want to store the inputted text into.

So.. here's an example...
- I want a user to enter text.
- I'll store it into a variable like $inputText.
- I want to split the text from $inputText into 30 equal sections and store each section into an element in the variable.
- I don't care if the words get separated during the filter, as long as the whitespaces stay where they are.

Could anyone give me some tips to help me get started or point me towards a tutorial or something?

Security With User Input And Sessions
I have two sort of related questions, if anyone would be so kind as to answer:

1. When I do an form for input (into a database) that is used for subsequently displaying on a web page, is there a function written to parse out all dodgy stuff, like putting HTML tags that could break the page, or filter out SQL that could corrupt or invalidate the entry or is there a regular expression that someone has already done to cover all areas?

2. If I am displaying data from a database and using sessions and the like, should I be putting something like this in my code (I found it in the php manual):

header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0

Cleaning Up User Form Input In Php
Does anyone please know why when trying to clear up user input that has been entered into a form, php only clears up most of it and not all?

For example, using stripslashes to remove all slashes from a variable after a user has submitted quotation marks ("") into a form.

The quotation marks cause the variable being parsed to contain slashes.

e.g. a user enters """""" into a form , the variable returned to php becomes """""

So if I only wanted the quotation marks, I thought the stripslashes function would achieve this.
However, it only removes 3 of the 5 slashes leaving 2 unwanted slashes behind.

Calling A Function Through User Input.
So heres yet another question to a problem where I would have no idea
where to look for the answer for so I turn to you :)

Say my sites administrator wants to write a news update or blog or
whatever. Something like this

"Added a new gallery from my trip to Phuket, enjoy:
[GID=24]
If you liked it tell me."

I want the [GID=24] to get replaced by my galery loading function
(very nifty and handy) so it would turn into something like this

echo "Added a new gallery from my trip to Phuket, enjoy:
".galery($GID)."
If you liked it tell me.";

I chose this [GID=24] because it is similar to burning board code. I
would also like to include a command like [PID=45] witch would run my
picture function.

Cleaning User Input, Is This Safe Enough?
I've written a small function that cleans up all user input before entering it to the DB. I'm wondering, is this sufficient or am I missing someting?

function clean_text($text) {

$text = str_replace("<", "&lt;", $text);
$text = str_replace(">", "&gt;", $text);
$text = strip_tags($text);
$text = htmlspecialchars($text, ENT_NOQUOTES);
$text = mysql_real_escape_string($text);

return $text;
}

Checking User Input With Eregi Function
The function below (ExpressionTest.php) is for checking user input. The function is supposed to permit only alphabetical characters, the apostrophe ('), and the dash (-) for the "FirstName" variable. For some reason the script below will permit the dash to be used but gives the message "Please enter a valid first name." message when the FirstName variable includes an apostrophe.

I have tried switching places for the dash and the apostrophe. But if I place the apostrophe first in the string and the dash second in the string I still get the same message. PHP Code:

How To Get User Input For A Variable Without Using Forms Or Tables
I have created forms and taken user input from the forms into php variables. When validating the fields, if i find my conditions not satisfied on the php variable, i ignore the database connectivity and display error message and having the user to go back to the page and correct the error.

Is there a way i can correct the error without going back to the page, and getting the particular user input without having to create another form or table for input into the php variable.

How Can Arrays Be Dynamic With User And Administrative Input.
Can someone please show me how by examples - how scalar and associatie arrays can be dynamic with the user and administrative imput.

Displaying Text Fields On User Input
How would I echo a particular amount of text fields depending on how many the user selects from a drop down menu that I have already created. For example say the user selects 4 or whatever other number from a drop down menu how would I echo 4 or whatever the amount of text fields for a user to input text into? An example would be an airline website were you select how many people are travelling and then it echo fields for those people to enter their names.

Unable To Insert User Input Into Ms Sql Database.
i have tried to insert user input into ms sql database but still unable to do so. my code has no errors in it. its just that the user input cannot be submitted into the ms sql database. Code:

What To Use In PHP To Make User Input Safe For MySQL Query?
I believe that you want to escape certain characters in a query, like quotes, backslash, semi-colon, etc. Is there a function in PHP to do all this for you and make the string safe to use as a query string?

User Local Time Diplay In Input Field
I'm wondering how can I have the local time of a user into a input field, it might sound or be stupid but even after my search I couldn't find a code si9mple enough, without any bla bla which each not my need.

Dynamically Creating URLS Based On User Input !
I am looking to create pages on the fly or dynamically based on user input. For example if i have www.example.com and they visit this and enter 'bob' in a textfield and press submit they create www.example.com/bob.html . How would I go about this ? I am guessing I need to create a folder when submit is pressed in my website directory ?

Cleaning User Input (Removing HTML/stripping Slashes Etc...)
How can I remove HTML and add slashes to a variable?

I know I can add slashes with addslashes($var); but I need to know how to remove all HTML at the same time. Also - Are there any other characters I should strip from the variable (it will be stored in a database and displayed on a web page).

Use Cookies To Save Info On What The User Enter Last Time In A Input?
I am having some trouble looking for a good tutorial on cookies and how to have them save what you last time entered in the form. So how can I do this so users don't have to renter everything the next time they try to post something on my site?

Php/sql Question - How To Build A Dynamic Query Statement Based On User Input
I need to build a query based on what the user checks in the form. For
example, if the user does not check certain fields, I don' tneed to use
those in the query statement.

Comparing User Input Values In A Form With Database Values
I want to compare user input values in a form with my database.
Basically I want to check whether the user exits in my database.
What mysql command can do that?

$_POST Behavior From Input=submit Vs Input-type=button
I have been trying to solve an annoying behavior with PHP (I think).
Maybe some of you have encountered the same and have some ideas.

I have an html form and I use an <input type="button"> element with
the onClick event that calls a javascript funtion. Once the script's
content has been processed, I execute the form.submit() directive.

I would like to combine the html form and the PHP script into one, and
use action="<?php echo($PHP_SELF) ?>".

When the html form has <input type="button" name="theButton"
value="thisisthetrigger" onclick="doThis(this.form)">but PHP cannot
'read' the value of $_POST["theButton"] after form.submit().

If I substitute the <input type="button"> for <input type="submit">
then PHP reads the value just fine. Some may argue to just use the
latter option, but that will cost me a trip back to the server to
basically do a lot of validation that can be very easily accomplished
on the client side.

PHPmyadmin Access Denied For User 'user'@'localhost'
WinMe machine as server, with Apache 2 installed and working PHP4 installed and working ( had PHP 5.05 installed and working, but i couldnt get the mysql extensions to load - phpinfo() didnt list mysql :(, so i installed PHP4, which now lists mysql when i run phpinfo). MYSQL 4.1 installed and working. I dont know the console commands too well, but i know its working ok, cos I have used a few simple DOS prompt commands to check its alive and I can connect to the database using MyODBC frontend/driver 3.51 and also using Navicat 2004.

When i try to connect to the database via PHPmyadmin from another network PC I have an error:

#1045 - Access denied for user 'user'@'localhost' (using password: YES)

I have played around alot with different settings in the config.inc.php file.... nothing seems to work.

This almost appears to be a simple login problem ( probably is too), but I can access the database locally from the Winme machine with the username and password that wont work over the network!

I have tried not using 'localhost' as the host name but the IP address of the Winme PC but I get this error:

#1130 - Host 'MYSERVERNAME' is not allowed to connect to this MySQL server

Notice: Use Of Undefined Constant User - Assumed 'user'
I have a script for a shopsystem on a Linux. There it works fine.
But when I try to run it on my Windows machine, PHP says things like

Notice: Use of undefined constant dbname - assumed 'dbname' in
c:apachehtdocsaposhop estshopclassesxxx.clas s.php on line 77

On Windows I run PHP 4.3.2
On Linux runs PHP 4.3.1

Authenticating User Common User Names
I want to create a password protected page with PHP and Mysql. I have 2 groups User and Admin. The respective groups have a common user/password. The user/password are stored in a database. I want to authenticate the user through a login form and not through a pop-up ($PHP_AUTH_USER) way.

What I want is, if a user logs in and he moves from one page to another, he should not be asked for validity again. Is this possible only with scripting (without session and $PHP_AUTH...). If yes - how do I keep track of an authorised user and unauthorised user, so that he should not be validated again. Does setting the user variable to global in all the pages do the trick.?

User Authentication And PHP Saving As Specific User.
the users of my server had to upload their pages by sftp and only the user who uploaded a page was able to edit itafterwards.

I've been asked to make a secure way for users to log on through the web and edit their pages online. However, although using .htaccess to authenticate users, the script saves as user 'nobody' and is not able to edit pages previously uploaded (and saved as user 'john_doe'). What I am trying to do is make the script save using the same username as the user used to log on.

Fill Fields When User Selects User From DB
I have a field with a selectbox which contains a list of client names and several other fields which display information from the DB.

I need to be able to make the fields change to the appropriate information when a user is selected from the select box. Can anybody please give me an example of a bit of code that will do this?

How Do Remove A User From MySQL.user?
How do you permanently remove a user from the MySQL database.

Delete from MySQL.user where user="Unwanted User";

just seems to ignored.

Need Help With Exec()
On Redhat linux, the command "passwd user" is interactive, so how can I pass data to and from the command with system() or exec()?

Exec();
well i know that exec("ndc reload"); would perform that command.. but i want too print out on the page what the command tells when i do like this:
[root@xermin cryzeck]# ndc reload
Reload initiated.
[root@xermin cryzeck]#

i want to print that Reload initiated. on the page.. how? not just echo("reload initiated"); but the stuff the command tells.

Exec()
When using exec(), how can I get it to display error messages when the command is not successful.I have tried Code:

$command = "dir";
$output = `$command`;
echo "$output";

Which works great if everything goes as planned. However, if anything runs that is not successful, I just get a blank page. For example if I inserted "not a valid command" as the $command var I get a blank page, and I want to get the "program is not recognized" dialog.

Using Exec()
I'm trying to use the exec() function to call shell scripts that in turn startup various programs under linux.. for example, when someone clicks on a link to restart a particular daemon, the daemon will then simply executed, either through the standalone command of /location/daemon or through the calling of a shell script that essentially performs an identical task.

My problem is that exec() seems to only work through the user "nobody," which the Apache web server is running under. The scripts and programs I'd like to execute are under a user account named "admin."

I've even tried chmod'ing all pertinent files w/ permissions that "nobody" could use to successfully access all necessary commands, without success, as the programs seem to crash whenever I do this.

PHP And Exec(dir)
I have been using opendir and scandir, but I want to try something
else.
Idea: using dir, and a) getting the result b) saving it as a file.

As I have problems with executing files directly, it create a bat file
and executes that.
I can execute command, but by some reason I dont get any response (it
should return something, and I get "")
The missing response is why I create a file.

I create the file on the network ( serversomewhere ) like this

dir "serversomewherefilesdir" >"serversomewhere
esult.txt"

Here is the odd thing: dir cannot read from the network - the bat file
is created there, it creates the result.txt file, but emtpy as it
cannot read from the network. Reading from c: and it works.

Exec()
on my linux-mysql-php3 system the exec() command doesn't do anything. I think I have permissions right and according to /usr/local/lib/php3.ini is oho not running in save mode.

Exec()
I'm having difficulties running an external program from inside PHP. I'm trying to create thumbnails using ImageMagick's convert utility using the following program: PHP Code:

Php Exec();
i've been trying to create a php script that writes some text to a
file, then runs the perl interpreter on the file and shows the output.
it works ok when valid perl is written to the file, so if i use 'print
"hello world";' then it outputs 'hello world'. the problem is, if i
enter invalid perl code, such as 'blahblahblah;', it outputs nothing.
i'd like the php script to be able to get the error/output. does anyone
know of a way to do this?

Exec(); & Php As CGI...
I have had to do some work on a RAQ server with php as cgi. The script I have written uses the exec(); function to run pgp to encrypt a file. Weird thing is this:

The script does everything it's supposed to but I get the RAQ internal server error message. Should I be using passthru of something else in this environment? Forgive me I am a relative virgin as far as RAQs and php as cgi goes.


Copyright © 2005-08 www.BigResource.com, All rights reserved