Tag Archives: file

mod_perl can't see files in /tmp

Questions: I have some mod_perl code trying to access a file under /tmp … but it throws a ‘no such file or directory’ error. I added an ‘ls -al /tmp’ to my code to see what Perl was seeing inside the directory, and it only gave me . and .. : drwxrwxrwt. 2 root root… Read More »

file_get_contents 1 minute timeout for https?

Questions: I’m having difficulty with PHP’s file_get_contents hanging for 60s when accessing certain resources over https. I’m not sure whether it’s a client or server end issue. On the client Working on the command line: $ URL=”https://example.com/some/path” $ wget “$URL” -O /dev/null -q # takes a few milliseconds $ curl “$URL” >/dev/null # takes a… Read More »

iterate over apache 2 log file names and compare numbers using linux bash

Questions: Here is an example of logs in my /var/www/apache2/log folder- ./no_domain_access.log.7.gz ./no_domain_access.log.8.gz ./no_domain_access.log.9.gz ./no_domain_error.log.10.gz ./no_domain_error.log.11.gz ./no_domain_error.log.12.gz ./no_domain_error.log.13.gz ./no_domain_error.log.14.gz ./no_domain_error.log.15.gz ./no_domain_error.log.16.gz ./no_domain_error.log.17.gz ./no_domain_error.log.18.gz ./no_domain_error.log.19.gz ./no_domain_error.log.20.gz and goes until 50… I would like to iterate over those files and remove all log files that are greater then 5. using regex syntax will give me the option… Read More »

How to prevent uploaded file from being executed?

Questions: How can i prevent uploaded file from being executed? For example, someone could upload php file and use it to hack site, i want to prevent it. Best that way that i know is using directory permissions, and set it to 666? Is there some htaccess magic that i can do? Answers: You can… Read More »

Java Apache FileUtils readFileToString and writeStringToFile problems

Questions: I need to parse a java file (actually a .pdf) to an String and go back to a file. Between those process I’ll apply some patches to the given string, but this is not important in this case. I’ve developed the following JUnit test case: String f1String=FileUtils.readFileToString(f1); File temp=File.createTempFile(“deleteme”, “deleteme”); FileUtils.writeStringToFile(temp, f1String); assertTrue(FileUtils.contentEquals(f1, temp));… Read More »

Creating executable file for Linux using Mono?

Questions: I want to develop a C# tool which shall be run on an Apache Web Server whenever it is called via PHP (e.g. using the exec-command). Since I am new to this it would be great if you can help me: 1) If I compile the C#-code on my Windows-system using the Mono and… Read More »

How to prevent one file from .htaccess redirect?

Questions: I am creating php front controller. this is my .htaccess file. <IfModule mod_rewrite.c> RewriteEngine on RewriteRule (.*) controller.php [L] </IfModule> This code redirect all url to the controller.php. I need to avoid redirect index.php to the controller.php. All other urls should redirect to the controller.php. Answers: You can use the following syntax to make… Read More »

Suspecious requests in apache web server log file

Questions: I found the Folowing requests in my apache web server. is these are hack attempts? will it be hamful to server. My server is crashing frequently and don’t have the reasons for It, GET /muieblackcat HTTP/1.1″ 302 214 GET //index.php HTTP/1.1″ 302 214 GET //admin/index.php HTTP/1.1″ 302 214 GET //admin/pma/index.php HTTP/1.1″ 302 214 GET… Read More »