PHP - Exec Function In Php 4 And Iis7 On Windows Server 2003
I have a PHP script containing the function exec which works fine in PHP 4 in IIS 7 on Windows 7. However this function does not work in PHP 4 in IIS 5 on windows server 2003. But I have to make it work there because that is what we have on our web server.
Can someone provide a solution? Similar TutorialsI have a PHP web system that store in a windows server. In the system, there is a function for user to upload files to another server (Shared server in Unix). When i try to upload a file, it gives warning: Warning: move_uploaded_file(\\unixserver/sharedfolder/upload/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\upload\index.php on line 40 For your information, my username has been assigned in xxx's group that has access to read and write on that folder. Besides, i'm able to open,create and delete files on that folder's server manually (samba). The safe mode setting is off. Does anybody has any idea why this thing happen? Hi all, I am a newbie to PHP. I'm trying to execute a program from my PHP script by calling the exec() function of PHP. It works fine when i try it from command line, or execute the script in command line. But when i call it from a php script in my apache, it does nothing. No errors are thrown. What i get in return is only an empty array. i'm using Ubuntu 11.10 and Apache 2.2 with PHP 5.3.3 thanks for helping me. guys i wand to execute a program on my seerver, i use the $_SESSION['tmp'] = exec("print.exe", $results); and works but when i change the directory $_SESSION['tmp'] = exec("d:\\print\\user1\\print.exe", $results); dont work, works only in root directory, is any way to set the execution to other directorys?? thanks Do you need to compile your own version of PHP with SSH extensions in order to use SSH with PHP running on a Windows Server? Hmm, hello everyone, i'm running my php in an ubuntu server and I'm trying to run a command using exec (i.e. 'echo 1 > /var/www/test.txt') but I always get a permission denied issue, although i've already changed the permissions to 777 (read-write-execute) Any solution? I have a username alam for the server I have sudo access to execute linux commands. I could configure almost all files the root can do. I wrote this script on the server for test as I need to provide the server some functionality ----------------- Code: [Select] <?php $cmd="ls -l"; echo exec($cmd,$ret_value) . "<br />DONE"; echo "<pre>".shell_exec($cmd)."</pre>DONE"; ?> ------------------ I get the OUTPUT as follows - ------------------ DONE DONE -------------------- I am novice user of Linux however any kind of help will be appreciated .......... Hi I'm trying to resize pictures for thumbnails I can do this correctly at linux command line with the following command convert ideologies.jpeg -resize 300x200 ./Thumbnails/testphp.jpg However trying to wrap this in PHP doesn't seem to work // Upload file to server if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){ // Insert image file name into database $insert = $conn->query("INSERT into Threads (Title, ThreadBody, filename) VALUES ('$Title', '$BodyText', '$fileName')"); if($insert){ $statusMsg = "The file ".$fileName. " has been uploaded successfully."; exec("convert {['fileName']} -resize 300x200 wankertestphp.jpg"); } If you look above I do successfully hit the "The File has been uploaded successfully" line so it is entering that If statement. I've also checked the Threads table with a Select * from Threads and I can see the $fileName variable is entering there. I've tried numerous different ways around the $fileName variable (removing the brackets...removing the brackets and the apostrophes")
Any help is appreciated. hi guys. i'm new to php and Apache and i have a problem. i'm trying to execute an exe file that i have in my folder, and the code i use is Code: [Select] echo exec('test.exe');i have tried using this with and without the ".exe." and still no luck. i have also tried using a different path Code: [Select] echo exec('C:\Windows\System32\mspaint');now these codes work when i run them from my php editor(PhpED), bun when i try running it on Apache it gets stuck. (just shows the web page as loading with no end. please help me out. i'm guessing it something with security. also if there is any other code i can use please let me know (i have also tried using system) Hi, I'm trying to build a 'simple' page to improve a process where I work.
I'm wanting to do this.
Read either the last line, the last 10 lines, or something I decide on from a log and display the output in table rows and columns.
I've done this before with loops and db query's, but don't know how to approach it using php only as this is the first time I'm using it.
So right now I have this in a table but it will only display one row.
<tr><td colspan="5"> how do i enable exec() in php.ini? where is php.ini? cant find it in the directories in my site. I set up functionality for a client that got moved to their server after I wrote and tested the functionality. It does not work on their server and I am trying to trouble shoot the problem as I do not have ftp access to the server.
I believe that I have narrowed it down to either I do not know how to access the temp files on their server, Windows IIS, OR the security on the server is not allowing me to upload to the temp files.
Here is the form used to upload to the server.
<form enctype="multipart/form-data" action="#" method="post" > <input type="hidden" name="upload_csv" value="TRUE" /> <p><label for="userfile">Upload CSV:</label> <input type="hidden" name="MAX_FILE_SIZE" value="45000000" /> <input type="file" id="userfile" name="userfile" title="userfile" value="" /></p> <p><input type="submit" name="upload_csv" value="Upload CSV" /></p> </form> Here is the test code: <?php $csvfile = $_FILES['userfile']['tmp_name']; $size = $_FILES['userfile']['size']; if($_POST['upload_csv']){ //---------------------------------validation code here if($problem){ echo '<div class="error">Did not pass validation</div>'; include("upload_csv.inc.php"); }else{ if (($handle = fopen($csvfile, "r")) !== FALSE) { //--------------------------------------------------------------this is where the code that imports the data from the csv and to the database goes echo '<div class="message"><p>CSV has been opened!</p></div>'; }elseif(!$csvfile){ echo '<div class="error">Problem #1</div>'; }else{ echo '<div class="error">Problem #2</div>'; } } }else{ include("upload_csv.inc.php"); } ?> This code generated the error message: Problem #2. One more bit of information: the permissions on the server is set so that nothing can be uploaded by an external script. I do not know much about servers, but it seems to me that because the security is so tight on the server, the security is the reason that this does not work...??? I appreciate help with this. I just am not knowledgeable on how the $_FILES['userfile']['tmp_name'] code actually works? Before reading, just know I am NOT a PHP programmer and have no experience with PHP. I am just trying to install a premade php based website.
My questions is: How do I make .php pages connect to my database?
I know the question is very broad and probably doesn't really make sense but I've been having errors trying to install/configure a php website. The php website has a config which I have filled out correctly and seems to work on my PC via localhost using XAMPP fine but it doesn't work on my Windows Server 2012 Apache machine whenever the .php configuration tries to alter or conenct to the MySQL database it displays errors like this:
Fatal error: Call to undefined function mysql_connect() in C:\Apache24\htdocs\includes\classes.php on line 378
That's just an example of one predefined PHP website errors that I've received they are all very similar. What I think is happening is the PHP code is trying to connect to the database but there's some sort of configuration variable on Apache that I have not correctly filled out. I have tried this twice with two different CMS and searched google far and wide to find an answer to my problem. I hope the answer is something simple. If you need anything because you think you know what is happening then I will provide any information needed to fix this problem.
Thank you.
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=352526.0 Hey guys I usually code in C and I started looking into PHP which I think is pretty good. I'm wondering if there's a function that can be used to execute a command from a remote server on my local machine??? As example if I'd like to have a PHP page/script running on my server which when logged onto would display me a page with buttons like "PING, NETSTAT, IPCONFIG, TRACERT" and when clicked on it would exec those commands but not on the server but from my machine??? So that I would get the PING from my local machine to google.com instead of from the server to google.com ??? making any sense ??? thanks This topic has been moved to Installation in Windows. http://www.phpfreaks.com/forums/index.php?topic=318822.0 Hi Friends, I wanted to know how can I go about using PHP to login into an SBS company web, I know I can do it through https://usernameassword@server.com/folder using a link but i don't really want to show the login details. Can curl handle this or is there another method? Thanks Hi All I have been working on a project in PHP for about three months. I have been happily working away with a WAMP server locally all that time. The problem arose today when I uploaded the project to a web server. I uploaded all the files by FTP and imported a mysql database on the new web server. When I went to view my home page I got the following error: Parse error: syntax error, unexpected T_STRING in /home/priestbr/public_html/output_fns.php on line 1 My index page references an include to a page which stores my functions: <?php error_reporting(E_ALL ^ E_NOTICE); session_start(); include('priest_br_fns.php'); The priest_br_fns.php then includes a further 3 includes as below: <?php include_once('db_fns.php'); include_once('output_fns.php'); include_once('general_fns.php'); ?> PHP seems to parse the db_fns.php page OK and fails at output_fns.php (as per the parse error msg). But here's the thing....during some investigation I deleted the contents of db_fns.php and pasted in the contents of output_fns.php and then the page got parsed OK! Anyone have any idea why it's failing? Is it something to do with how I have the includes set up? I really need all the includes working obviously for the site to run. For info my local server where the site works perfectly is set up as below: PHP 5.2.6, MySQL 5.0.51a, Apache 2.2.8 The web server is set up like this: PHP 5.2.1.14, MySQL 5.0.91, Apache 2.2.16. Thanks in advance, Craig Most of the time my localhost works like a champ but occasionally I get ... mysqli_connect() [function.mysqli-connect]: (HY000/2005): Unknown MySQL server host 'localhost' (11001) On phpfreaks I've searched for "Unknown MySQL server host localhost " and didn't see an answer to this problem Then I googled and found this http://stackoverflow...-localhost11001 However in this file the localhost ip is commented out and windows wont let me edit the file to uncomment it like it's done in the stackflow post. So, one is this the likely problem ... and if it is how do I edit a file in the Windows folder? As a note I do go into the file as the administrator using notepad Thanks Edited by floridaflatlander, 03 June 2014 - 08:21 AM. i have a bash script that i was running with cron jobs: #! /bin/bash start=1000 homedir="/home/alin/NetBeansProjects/Fragger2" numberofprocess=`expr $start + $2` i=$start currentnumber=`ps ax | grep index | grep -c php` case "$1" in start) while [ $i -lt $numberofprocess ] do if [ `ps axo cmd | grep index | grep php | grep -c $i` -lt 1 ] ; then /server/php/bin/php $homedir/index.php $i & fi; i=`expr $i + 1` done ;; stop) while [ $currentnumber -ne 0 ] do kill -9 `ps ax | grep php | grep index | awk {'print $1'} | head -n 1`; currentnumber=`ps ax | grep index | grep -c php` done ;; *) echo "Usage : " $0 "start|stop" ;; esac exit 0 and it was working fine, now i'm tring to make it run from a page . if(isset ($_POST['stop'])){ $conn->update("update `links` set `proccess`=0 "); exec("/home/alin/NetBeansProjects/Fragger2/Trans stop 0"); } if(isset ($_POST['start'])){ if(!preg_match("/^[0-9]+$/", $_POST['proccess'])) echo "proccess should be only a number!"; exec("/home/alin/NetBeansProjects/Fragger2/Trans start ".$_POST['proccess']); } and i don't know why it is not working, i have set for this folder all the permision for this folder "chmod -R 777 /home/alin" it doesn't stop running and i can't figure out why i have to kill the procces from the comand line to stop Hello, I was just seeing if someone could push me in the right direction. I have a form that uploads items to a database and it also includes uploading images to a directory as a part of that. That all works, but I was thinking for security it'd be best not to leave that directory as 0777 for permissions. In researching this I found the exec() function. I'm still figuring out the relation of who the permissions are associated with and why. All I know is if the directory has 0777 for permissions my script works just fine. I was just seeing if using exec to change the permissions during the process of uploading the images and then change back would be cumbersome and leave open other problems (there won't be any user-based input being passed to that) or if that actually would be the way to go for this. Thanks! -Frank |