Jump to content

Search the Community

Showing results for tags 'piped emails'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I am trying to extract csv attachments from emails that have been piped to a php script. The pipe is working, and for the most part the php script is working as well. Unless someone sends the csv file from a source such as an apple iphone. Then the script begins on the wrong line to start the data extraction. Can anyone help me fine tune this to work cleaner?? OR is there simply a better way to extract an attachment from a piped email? Thanks! #!/usr/bin/php -q <?PHP ## sql connection credentials go here. $fd = fopen("php://stdin", "r"); if ($fd) { $t='0'; while (($fde = fgets($fd, 4096)) !== false) { ## Opens the email and saves each line into an array called $email ## $email[$t] = $fde; # $message .= $fde; $t++; } fclose($fd); for ($h='0'; $h<$t; $h++) { ## Splits each line by comma and checks position [0] for specific wording the first line in the csv file. saves line position once found ## $output = explode(",",$email[$h]); if ($output[0] == "item location") { $j = $h+2; # on line $j because that is where I found the item location } } $l='0'; for ($b=$j; $b<$t; $b++) { $pos2 = strrpos($email[$b], "_NextPart_"); if ($pos2 === false) { $pos = strrpos($email[$b], "="); if ($pos === false) { $themail[$l] = $email[$b]; } else { # Addresses a problem of = signs showing up. if I see an = sign combine the next two rows into one row and remove the equals sign. AND add 2 to $b instead of 1 $z=$b+1; $e = array('"', '='); $themail[$l] = "".str_replace($e, '', $email[$b])."".$email[$z].""; $b++; } } else { $b=$t; } $l++; } ## starting point is $j $i=0; for ($k=0; $k<$l; $k++) { ## Splits each line by comma and saves each item from each line to an array ## $output = explode(",",$themail[$k]); foreach ($output as $value) { $foutput[$i] = $value; $i++; } } $r='0'; if ($l > 50) { ## this is done to limit the number of rows being uploaded at one time to 50 max. For some reason, the script starts to get out of sync after 55 rows are processed. 50 seems appropriate anyway ## $l = 50; } for ($e='0'; $e<$l; $e++) { #echo "<br>Set $e <br>"; $r=$e*8; $s='0'; for ($w=$r; $w<$r+8; $w++) { $line[$s] = $foutput[$w]; ## upload the data here ## $s++; } ## sql SELECT statement looks for existing matching data, if it find it then it UPDATEs the line, if not then it INSERTs the line. ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.