Solved

allow me to write a file without getting a warning

Posted on 2013-01-13
4
354 Views
Last Modified: 2013-01-14
#!/usr/bin/php -q
<?php // RAY_temp_rgb192.php
mail('gmail@gmail.com','subject','body');
//error_reporting(E_ALL);
//ini_set( "display_errors", 0);
ini_set("display_errors", FALSE);
ob_start();
date_default_timezone_set('America/Chicago');


// THIS IS THE SORT OF THING THAT MIGHT BE FOUND BY THE EMAIL PIPE
$email = <<<ENDEMAIL
MIME-Version: 1.0
Received: by 10.217.5.194 with HTTP; Tue, 23 Oct 2012 07:02:46 -0700 (PDT)
Date: Tue, 23 Oct 2012 10:02:46 -0400
Delivered-To: ray.paseur@gmail.com
Message-ID: <CALik7L8mmDoneUaWdO+Or1MJFFDQ27YJtEd7Gx_hut9Th_dSww@mail.gmail.com>
Subject: A Sample Message
From: Ray <ray.paseur@gmail.com>
To: Ray <ray.paseur@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hello World
ENDEMAIL;


// A REGULAR EXPRESSION TO FIND THE FROM-EMAIL ADDRESS
$regex
= '#'         //REGEX DELIMITER
. 'From:'     // LITERAL STRING
. '.*?'       // ANYTHING OR NOTHING
. '\<'        // ESCAPED WICKET
. '(.*?)'     // GROUP OF CHARACTERS WITH EMAIL ADDRESS
. '\>'        // ESCAPED WICKET
. '#'         // REGEX DELIMITER
;

// A DATE PATTERN THAT WILL CREATE ISO-8601 FORMAT
$datep = 'Y_m_d_H_i_s_';

// ISOLATE THE FROM EMAIL ADDRESS
$from = preg_match($regex, $email, $matches);

// REMOVE DOTS
$from = str_replace('.', '_', $matches[1]);

// REMOVE @-SIGN
$from = str_replace('@', '_AT_', $from);

// PREFIX DATETIME AND SUFFIX FILE TYPE
$file = date($datep) . $from . '.txt';


// WRITE THE FILE
//file_put_contents($file, $email);
//echo "FILE: <b>$file</b> WRITTEN";

Open in new window


hostgator shared hosting


file_put_contents($file, $email);

when this line is uncommented I get an warning in the gmail


PHP Warning:  file_put_contents(2013_01_13_20_42_01_ray_paseur_AT_gmail_com.txt): failed to open stream: Permission denied in /folder/pipe.php

even though the file is written


I want to suppress the writing of warning because gmail sends me a failure email back
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
un1x86 earned 250 total points
ID: 38773614
you can supress the message by adding an @ as a prefix of your function

@file_put_contents($file, $email);

Open in new window

0
 
LVL 35

Assisted Solution

by:gr8gonzo
gr8gonzo earned 250 total points
ID: 38774084
I'm very surprised that the file is written if you are getting that message. Are you absolutely 100% certain that the file is being written?
0
 

Author Comment

by:rgb192
ID: 38776924
@
suppresses the warning and the gmail error email


the file is not being written: when I use a pipe (via email)
but gets written when I run file in browser
0
 

Author Closing Comment

by:rgb192
ID: 38776933
you are both correct

the pipe required me to write the entire file path

and

@
hides the warning (which does not exist now)

thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WordPress  Failed to Import Media 8 67
CSV export single column not inserting comma's in file 11 69
Can't find an open element in HTML 5 55
Phone number mask 4 16
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question