fopen

Cannot open a local file using fopen()

HI. i am trying to open a local file from xml created by xlink i have parsed the file path in $resourceRef variable and it looks like that file:/./birds/birds.txt without the quotes. Please someone tell me why i cant open it. here is my code $fh = fopen($resourceRef, 'r'); $theData = fread($fh, filesize($resourceRef)); fclose($fh); ech...

Why is fopen() behaving like this????

I am currently working on this project which requires me to make a function which dinamically decides the directory name and then creates a simple .txt file in that directory. my code is as follows: ($destinatario is a string) $diretorio="../messages/".$destinatario; if (is_dir($diretorio)) { ; }else{ mkdir($diretorio); } ...

php fopen ftp_get changing owner/group - sometimes - why?

On my php host, I have a script that is run by a cron job that opens/overwrites a file from a remote ftp server. It works most of the time, but I am finding that when it initially creates the file, the owner/group are "736/736", but at some point the owner and group change to "99/99". Problem is I start running in to permissions issues...

Opening a file in 'a+ 'mode

If a file is opened using the following command: FILE *f1=fopen("test.dat","a+"); The man page reads: a+ Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but...

fopen file locking in PHP (reader/writer type of situation)

I have a scenario where one PHP process is writing a file about 3 times a second, and then several PHP processes are reading this file. This file is esentially a cache. Our website has a very insistent polling, for data that changes constantly, and we don't want every visitor to hit the DB every time they poll, so we have a cron proces...

In PHP, how can i get fopen to timeout very fast when opening a local file?

I'm having a problem with PHP where i'm writing to a file very often, and sometimes it takes a long time to open that file. The complete description is here: http://stackoverflow.com/questions/3759345/fopen-file-locking-in-php-reader-writer-type-of-situation My question is how can I get fopen to timeout in, say, 50ms. I looked at strea...

PHP - Change fopen to curl

Hi! I use this function with 'fpoen', but I need to use 'curl' instead. function rest_auth_xml($url,$method,$token,$chave,$xml) { $auth = sprintf('Authorization: Basic %s',base64_encode("$token:$chave") ); $opts = array( 'http'=>array( 'method'=>$method, 'header'=>"Content-Type: text/xml\r\n" . $auth."\r\n", 'conten...

using curl instead of fopen problems

So, I have been lumped with trying to fix a php script we have on our remote access page. Originally it would use fopen to if a site was available. If it was the user would be directed to that site, if it was down the next url would be tested and the user redirected there if it was successful etc etc. Our new shared hosting site does ...

Why does my server keep creating new files with 0640 permissions in my PHP fwrite?

I'm using a simple fopen("w") and fwrite setup to write a new file on my server. Recently, this has been arbitrarily assigning 0640 permissions to these files, which means I can't view them from a browser. But it's not happening every time. Can anybody tell me why? What I'm missing here? Here's my code: if ($file=fopen("$filesDir/$yr/$m...

Does MATLAB lock files when it opens them (Linux)?

I'm collecting data and would like to plot the results in Matlab as they're being collected. However it seems like the file would be locked while my scripts are running. Does anyone know if the Linux version of Matlab acts differently when it opens files, and leaves them writeable by other processes? ...

PHP file_get_contents after php has evaluated

Hey guys, I know how to use file_get_contents and fopen etc, but when I do it to one of my own file, I get the literal string, meaning, the code is not preprocessed! How can i import text from a file without using require etc. because I want to store the value into a string ...

Any other good option for fsockopen?

I'm trying to make the code below work with curl or something. I have already taken a look at the curl fsockopen conversion but it doesn't work. The code works except that fsockopen is disabled on my host. Any help will be appreciated. $host = substr($hostport,0,50); $port = substr($hostport,50,10); $issecure = substr($hostport,60,1); ...

Query regarding main() of GRUB

Below is the code of main() of grub. Here I want to know about this line: file = fopen(arg_v[1], "rb"); Here which file fopen is opening? What file this arg v[1] is pointing to? int main(unsigned arg_c, char *arg_v[]) { FILE *file; if(arg_c < 2) { printf("Checks if file is Multiboot compatible...

fopen fails is file opened in visual studio

I have the following code : FILE *fp = fopen( srcFile.filename.c_str(), "rt" ); srcFile happens to be the solution's main.cpp file, and thus is opened in the solution. fopen returns NULL most of the time (but not when I step into it, which is weird). However, when I close main.cpp in Visual Studio, the code works. Even when the fil...

Why is there extra whitespace at the beginning of my file after I write it with PHP?

Hello there, I am trying to make my PHP script create a file and add headers into that file but the file must be PHP only and nothing before the PHP tags. But the script is for some reason adding an extra blank line in the beginning before the <?php and it does not work. I know this because when I manually edited it and removed the line...

Detecting file deletion after fopen.

Hi im working in a code that detects changes in a file (a log file) then its process the changes with the help of fseek and ftell. but if the file get deleted and changed (with logrotate) the program stops but not dies, because it not detect more changes (even if the file is recreated). fseek dont show errors and eiter ftell. how i can...

How to enable large file support under Darwin?

I have a C application I am trying to compile for Mac OS X 10.6.4: $ uname -v Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 My gcc is as follows: $ gcc --version i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664) My Makefile is as follows: CC=gcc CFLAGS=-D_FILE_OFFSET_B...

open_basedir won't let me write file, but directory seems correct?

Short story: I'm getting an open_basedir restriction in my php script - a simple "test writing a new file to disk" script. It SEEMS to me that I've got the open_basedir settings correct and the file is in the right location - but no luck, just the same error every time. I've searched for similar open_basedir problems on this site, but...

PHP image grab when allow_url_fopen=off

I am using thesis theme on my wordpress blog. I am hosting my blog at byethost which has allow_url_fopen=Off and allow_url_include=Off In one of the function, code is trying to read an image url path. From what I understand, if fopen is ON, it will execute "if" case otherwise "else" case if ($thesis_design->image['fopen']) $imag...

Why does fopen produce varying files from calls to Twitter, when the file should be static?

Hi, I am trying to get a list of Twitter users using their API. When I query the API in my browser (http://api.twitter.com/1/statuses/followers.xml?screen_name=atomictom), it returns an XML doc with 100 users, as it should. However, when performing the query from my php file: $file=fopen("http://api.twitter.com/1/statuses/followers.xm...