PHP - Moved: Can T Move File: Php-error Handling In A Apache 2 Server Needet
This topic has been moved to PHP Applications.
http://www.phpfreaks.com/forums/index.php?topic=351056.0 Similar TutorialsThis topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=333987.0 How to reliably determine if server is Apache using PHP? For example isApache() function? So, I'm trying to read a file from a different filepath than the current working directory.
I have some simple PHP like this :
<?php $input_map = "readfile.php"; $map_contents = file_get_contents($input_map); echo $map_contents."<br />\n"; ?>And this'll work fine because it's in the same directory but if I try to set $input_map = "/home/...", the browser will return an empty string. This script will work from the command line though. So how do I get file_get_contents() to read from the server's file structure instead of just the working directory? Edit : For example, this will not work through the browser : <?php $input_map = "/home/..."; $map_contents = file_get_contents($input_map); echo $map_contents."<br />\n"; var_dump($map_contents); ?> Edited by MutantJohn, 21 January 2015 - 06:35 PM. I implemented google's reCAPTCHA V2 on http:// on the remote apache shared server and it worked 100%. I then changed the protocol to my shared server SSL using the same PHP script as the non-SSL script. The older version of reCaptcha had an SSL 'false' to 'true' SSL parameter, whereas I can't find one for V2. I had to use htaccess to redirect the example.com to the shared SSL server https://serverid.net/example/ which works perfectly without recCAPTCHA. I incorporated reCAPTCHA V2 and the error message where the reCAPTCHA image should be shows "ERROR: Invalid domain for site key". I am using apache web server on linux. I am using PHP for web designing. On web server, i want to show the configuration data by reading the ini file. I am creating this ini file from one php code itself. If this php code i run through linux terminal, the file is created with file and group owner as root.(i am having sudo rights on machine) Then if i try to read the ini file from my apache web server, it gives warning as failed to open stream: permission denied. I have tried changing the owner, and permissions to 777 of the file. Still it is not readable.
On the other hand, if i run the php code of ini file creation through web server, ini file is created with file and group owner as apche. and web server is able to read/ write the file.
But i want to create that file from root or some other user and later read/written by apache.
How to give this access permission?
Hi, I have created a script that connects to an FTP SERVER... downloads a movie file to the web server then uploads it to a target FTP server. If I move a small file of say 10mb it works well! But if I move a larger moviefile such as a 700mb file it doesn't... The only thing I can think is there is some sort of timeout... Any pointers would be a massive help! I have tried to increase the FTP timeout and also enabled passive mode Code: [Select] ftp_set_option($conn2, FTP_TIMEOUT_SEC, 600); Code: [Select] <?php $movefile = "movie 2.avi"; $server1 = array( "Name" =>"Downloads", "Host" =>"10.0.1.3", "User" =>"Paulio", "Pass" =>"lol", "Path" =>"/Download/Completed"); $server2 = array( "Name" =>"files", "Host" =>"10.0.1.2", "User" =>"Paulio", "Pass" =>"lol", "Path" =>"/Television"); ////////////////////////////////// Download file to be moved. ////////////////////////////////// // Connect to server $conn1 = ftp_connect($server1['Host']); // Open a session to an external ftp site $login1 = ftp_login ($conn1, $server1['User'], $server1['Pass']); ftp_pasv($conn1, true); // Check open if ((!$conn1) || (!$login1)) { echo "Ftp-connect failed!"; die; } else { echo "Connected to " . $server1['Name'] . " FTP server.<br><br>"; } [b]ftp_set_option($conn1, FTP_TIMEOUT_SEC, 600);[/b] ftp_chdir($conn1, $server1["Path"]); // Moves file to be moved to web NAS drive. ftp_get($conn1, $movefile, $movefile, FTP_BINARY); ////////////////////////////////// Upload file to be moved. ////////////////////////////////// // Connect to server $conn2 = ftp_connect($server2['Host']); // Open a session to an external ftp site $login2 = ftp_login ($conn2, $server2['User'], $server2['Pass']); ftp_pasv($conn2, true); // Check open if ((!$conn2) || (!$login2)) { echo "Ftp-connect failed!"; die; } else { echo "Connected to " . $server2['Name'] . " FTP server.<br><br>"; } [b]ftp_set_option($conn2, FTP_TIMEOUT_SEC, 600);[/b] ftp_chdir($conn2, $server2["Path"]); // Uploads moved file from web NAS drive to destination ftp_put($conn2, $movefile, $movefile, FTP_BINARY); //Deletes source file ftp_delete($conn1, $movefile); //Deletes temp file unlink($movefile); ftp_close($conn1); ftp_close($conn2); echo "Complete."; ?> Thanks, Paul. Hi. I am sending out email with a php script - about 5000 at a time by send 15 or so every 20 seconds which works fine. Sometimes I need to add an attachemnt. I then find that the script will keep stalling. Is there a way to test the server qmail/mail queue to see if it isready to send another message? - rather than send it and have the script stall? It may be enough to simply be able to check that the number of messages left to be sent in the queue? Have search a lot for help on this with no results. Any server/qmail experts out there? Thanks Paul This topic has been moved to Installation on Linux. http://www.phpfreaks.com/forums/index.php?topic=321601.0 I am working from my home computer using windows 8.1. I downloaded Xampp, installed notepad++ and created a simple echo statement using PHP. I then placed the statment into the htdocs file. Then I went to my browser and entered the path as localhost:81/invoice.php (I used 81 because 80 is used for another application). I also changed all of the locations where it defaulted to 80 (using the find function, so I know I covered them all). I still recieved this message below. I know they are seeing each other for two reasons.. 1. I get another error message when I make up a fake file path in localhost folder. 2. The error is a 404. Also, I can see Xampp dashboard at localhost:81/xampp. I am stumped. Could it be my security settings or the fact that I am on a home server? Also, could it be problem with having mysql and microsoft sql server 2008 R2 on the same machine? Any help would be awesome. Also, yes my Xampp is started up (Apache and Mysql). Thanks.
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404 localhost Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 Edited by Butterbean, 18 December 2014 - 11:16 PM. Hello, I have a site that i built about 2 years ago, and has worked fine with often usage since. Today, I get the Forbidden error on the executed document when going to edit a record. Funny thing is, i can insert into the textarea anything except the code that i am using, which is an iframe. Perms are 755 and as i have said, this has worked fine up until today... any thoughts? thanks for you help Joe. Code: [Select] http://localhost/link.php?course=fitness link.php Code: [Select] <?php $course=$_GET[course]; echo "$course"; ?> I install the new apache it come out with this error "Use of undefined constant course - assumed 'course' in C:\xampp\htdocs\link.php on line 2". Previouly it is working fine on old one. Why it happened on new apache? Day
I'm using Codeigniter and inside the framework I create a file with PHP code If I try to point to it, the web-server doesn't deliver due to permission issues.
All this is done in a 'register function' where I create some fields in a SQL
If I put the user credentials into the database 'by hand' and likewise when I
I'm pretty sure this issue has been existed before and I'd appreciate any help.
Thanks for your help in forward. Gee Edited August 17, 2020 by bogusHi there, I'm a .net developer and I've inherited a partially complete php project. I'm trying get part of it running on my pc and am running into some issues due to my fairly limited knowledge with php/apache web server. I'm using Windows Vista, I have Apache HTTP server 2.2 running and am using PHP 5.2.17. The aim is to send some data to the web server. I'm using this function below - public static function push_data($data) { $data = base64_encode(gzdeflate(ot::encrypt(serialize($data), otCRYPT_KEY), 9)); $data = http_build_query(array(otDATA_KEY => $data)); $opts = array ( 'http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n", 'content' => $data ) ); $ctx = stream_context_create($opts); return file_get_contents(otDATA_URL, 0, $ctx); } And am getting this message back - PHP Warning: file_get_contents(http://localhost/Epointment/ot/backend/data.php): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host failed to respond. I've echoed $ctx and get Resource ID #15 and echoed otDATA_URL and get http://localhost/Epointment/ot/backend/data.php, which is correct. I've run a test php script actually on the web server and it works, so at least I know the server is running and PHP works on it. I'm not sure if this is an issue with the Apache settings or the PHP script or php.ini settings thanks for any help, This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359558.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=351153.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347581.0 I am using apache web server on linux. I am using php for coding. My php code is not able to read the files from /var/tmp folder. If apache itself creates some files in /var/tmp folder then php code is able to read it. Why this permission denied issues are there though full access permissions are given to each file?
I have set an SQL field as unique so that duplicates can't be entered, however rather then having the page error out and show the Error: Duplicate entry 'entry' for key 'field' I would like to be able to have a little div appear and say something like "this entry already exists" I already have it set to show that the item has been added but I have no idea were to start to make this work. Any ideas? Thanks, Jim Hi I'm completely new to error handling in PHP and wanted to ask whether I'm doing it right and, if not, what the right way would look like class DBConnection { public function execute($sql) { $query = @pg_query($this->dbconn, $this->prepare($sql)); try { if (!$query) { throw new DBException(); } } catch (DBException $e) { echo "Query execution failed"; exit; } } } Hi, I'm a beginner in PHP OOP and I'm with some doubts about the correct way of handling errors in PHP. Look at this function for example: public function deleteFileFromDisk($fileNameToBeDeleted) { $handle = unlink($fileNameToBeDeleted); if (!$handle) { $result = "(this->deleteFileFromDisk) - Error, " . $fileNameToBeDeleted . " not deleted."; } else { $result = "(this->deleteFileFromDisk) - Success, " . $fileNameToBeDeleted . " deleted."; } return $result; } Is this the correct way of doing it, or I can do better than this? Let me add some details of what I'm achieving... I'm running class methods, and I need to control errors in the process. If any call to the object throw an error I need to catch, stop all the process and send an e-mail with the error. Here are the object interactions: $testar_classe = new geoIpImportCSV('geolitecity', 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/'); $testar_classe->downloadAndSaveFile('./', $testar_classe->obtainDownloadFileName()); $testar_classe->uncompressZipFile($testar_classe->obtainDownloadFileName(), '.'); $testar_classe->deleteLine(1, 'GeoLiteCity-Location.csv'); $testar_classe->deleteLine(1, 'GeoLiteCity-Blocks.csv'); $testar_classe->deleteDataFromTable('tabela1'); $testar_classe->deleteDataFromTable('tabela2'); $testar_classe->insertLinesToDb('GeoLiteCity-Location.csv', 'tabela1'); $testar_classe->insertLinesToDb('GeoLiteCity-Blocks.csv', 'tabela2'); $testar_classe->deleteFileFromDisk($testar_classe->obtainDownloadFileName()); $testar_classe->deleteFileFromDisk('GeoLiteCity-Blocks.csv'); $testar_classe->deleteFileFromDisk('GeoLiteCity-Location.csv'); Which is the best way of handle this? Create a new method to take care of the exceptions? There are any examples on how to do this? Best Regards. |