fopen

php fopen , str_replace

I need to open a file , replace some content( 12345 with 77348) and save it. As far I have $cookie_file_path=$path."/cookies/shipping-cookie".$unique; $handle = fopen($cookie_file_path, "r+"); $cookie_file_path = str_replace("12345", "77348", $cookie_file_path); fclose($handle); However it doesn't seem to work .... I would app...

Is fopen safe to use in public software?

I am creating a web application that I hope to release to the public for downloading and installing on anyone's own web server, however I just was informed that some webhosts disable the use of fopen in php due to "security issues", particularly on shared hosts. I use fopen during the installation process of the application, should I be ...

Truncate file ('w') not working for a chat application

Hello, I've made a chat application for a website. Everything is working fine, however, I am trying to make a situation where when the user clicks 'logout', the chat box system will show to other users that the specific user has indeed logged out of the room, and then it will proceed to clear all old messages on the user's screen who ha...

Overwrite file using append mode for fopen

I am using fopen to write to a binary file and using the cstdio (stdio.h) library due to legacy code and it must be cross-platform compatible with Windows and Linux. For the prototype, FILE * fopen ( const char * filename, const char * mode );, I am using const char * mode = "ab", which will append to a binary file. Writing operations ...

fopen fails mysteriously under Windows

Maybe I just have another black out but, this one line is giving me a lot of troubles: FILE *fp = fopen("data/world.data", "rb"); This works fine under Linux when compiled with GCC. But when I compile it with Visual Studio, it crashes. fp is always NULL. Both the BIN and the EXE are in the exact same directory. Now, to make things eve...

fopen file from windows network location

I can open files from a mounted network drive, but not from an unmounted one e.g \\mycomp\folder2\hi.bmp Any work around for this? ...

fopen returns Resource id #4

<?php $handle = fopen("https://graph.facebook.com/search?q=mark&amp;type=user&amp;access_token=2227470867|2.mLWDqcUsekDYZ_FQQXYnHw__.3600.1279803600-100001317997096|YxS1eGhjx2rpNYLNE9wLrfb5hMc.", "r"); echo $handle; ?> Why does it echo Resource id #4 instead of the page itself? ...

[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized

Hi there, [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized I am periodically getting this error, i.e it is only happening at random times, any ideas what would cause this, i have checked my php.ini and allow_url_fopen is set to true. ...

Why does fopen fail the first time, but work the second time?

Hi, I am using Matlab to create a new file by calling fid = fopen(filename,'w') since filename doesn't exist, it should create a new file and give me a valid file descriptor. Instead it returns -1. If I run the code again however, I get fid = 3. This is being run on ubuntu but it apparently works fine on windows and I can't figure ...

PHP fopen using file mask

Is it possible/how can I open a text file in PHP using a file mask? The files are going to be named for example: abcdef_072810_999222.txt abcdef_072910_123456.txt abcdef_073010_888884.txt So I want to fopen or rename the file like this (notice the * mask) : "abcdef_".date("mdy")."_*.txt" I would like to avoid a read directory conte...

SQLite VFS implementation guild lines with FOpen*

Hello I am about to implement a custom VFS (virtual file system) for a Netburner embedded device (non windows) using FOpen, FRead, FWrite, FSeek, and FClose. I was surprised that i could not find a FOpen* version of the VFS available. It would make it a lot more portable to embedded devices. I found some information on creating the V...

rewrite fopen into curl - script

I have no idea where to begin - my web host does not allow fopen, but my geocoding script below uses it. So, since no fopen - no lat & long - so no google maps on my pages. Can anyone redo this in curl? http://paste.ly/4HU (since the code is breaking up below) $mapaddress=str_replace(' ', '%20', $_REQUEST['street_num'] . ' ' . $_R...

How do I delete a file that's been fopen'd?

I'm using fopen and it's saving to my shared hosts /tmp directory. I fclose it, but the tmp file doesn't delete. How can I delete this? PHP5, btw. ...

best way to update congfig.php

I have a config.php file for one of my site which holds information needed to run the site. It somewhat looks like this: <?php $site_name="The Site"; $base_url = "http://site.com"; $upload_path = "/images"; ?> Getting the values from that is easy, I just use require 'config.php'; but how can i give an option to add this from a html ...

convert fopen to curl?

Hi everyone I have recently changed servers, and one of my scripts is not functioning on the new server, as fopen is not enabled? Is it possible to change the following code to use the CURL function instead? Hope someone can help! <?php $postToFileName = 'http://www.somesite.com/postfile.aspx'; $postArr = array( 'NM' => $row['Lead_...

Accessing Windows' special named folders in PHP fopen streams

Hi Everyone, http://en.wikipedia.org/wiki/Special_Folders I am having a problem with accessing a special folder in a fopen stream in php. Example $fp = fopen("%USERPROFILE%/Desktop/text.txt", 'wb'); fwrite($fp, $data); fclose($fp); I try this with sysinternals process monitor running to try and see what is actually happening and it...

PHP script gets progressively slower (file reader)

I have a script that, when put against a timer, gets progressively slower. It's fairly simple as all it does is reads a line, checks it then adds it to the database, then proceeds to the next line. Here's the output of it gradually getting worse: Record: #1,001 Memory: 1,355,360kb taking 1.84s Record: #1,001 Memory: 1,355,360kb taking...

fopen: Fatal error: Can't use function return value in write context in

I cannot seem to be able to figure out why I receive: Fatal error: Can't use function return value in write context in [path]/admincp/global.php(226) : eval()'d code on line 12 when I try to use fopen/fsockopen, and such functions to retrieve remote data. My code is: http://pastebin.com/crLB429N I have tried using fopen/fread, and fso...

PHP posting values to java servlet

Hi, I would like to post some values (for example boolean) from a php file to my Java Servlet. It is basically a notification system which i am trying to implement.The functionality is that a user posts a question to a website (built using php) and when ever he gets an answer to his question,i should be able to pass a boolean value fro...

Is there a reason fopen() wouldn't work after several hundred opens?

Hey, for this piece of code, the person who wrote the system communicates data between processes using textfiles. I have a loops that looks (for all intents and purposes) like this: while (true) { //get the most up-to-date info from the other processes pFile = fopen(paramsFileName, "r"); // Do a bunch of stuff with pFile Sleep(100...