Jump to content

tadakan

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    Washington State

tadakan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. It was the html entities. Thank you so much, I thought I needed to figured out how to use the mime parsing abilities of php and that was looking daunting.
  2. I've also tried changing the user account that the email server service starts under, but that didn't change any behavior. Any bright ideas?
  3. I'm trying to write a regex for a url that starts out with the same subdomain.domain and so and then deviates with the arguments that are sent to it. What I originally thought was working: %http://appraisalzone.lendervend.com/AssignOrder.aspx.[a-zA-Z0-9/?=&-]{1,}/.$% I'm parsing this out of an email and it turns out that email has the link somewhat different than it appears in a client. It looks like the link is partially in hex? anyway the print_r of the email from stdin() gives this link: <a = href=3D"http://appraisalzone.lendervend.com/AssignOrder.aspx?orderid=3D35= 7262&userid=3D116315&customerorderid=3DEFC33B67-A60D-434B-99E1-7D= 4FA5C9DA1C There are also either newline or carriage returns in there that I'm not sure how to allow for in the regex.
  4. Another interesting/frustrating quirk: this regex $reg_exUrl = '%http://appraisalzone.lendervend.com/AssignOrder.aspx.[a-zA-Z0-9/?=&-]{1,}%'; pulls all of the url "http://appraisalzone.lendervend.com/AssignOrder.aspx?orderid=357262&userid=116315&customerorderid=EFC33B67-A60D-434B-99E1-7D4FA5C9DA1C" when run from CLI but only reads through orderid=357262 when run by the email pipe.
  5. I confirmed that it's using php.exe either way. (One method isn't using php-win for example.) So that probably isn't the problem.
  6. Hi I've got a problem that I think belongs here, but otherwise please move it. I've been working on this script for a while function runbat($url) { $i = 1; //Set the path and filename $filename = ("C:\\temp\\output".$i.".bat"); //if the file exists renumber the filename and rewrite the variable while(file_exists($filename)){ $i++; $filename = ("C:\\temp\\output".$i.".bat"); } //create the next highest filename and write to the file. $handle = fopen($filename, "a"); $input = "@ECHO OFF \n"; $input .= "SET BROWSER=firefox.exe \n"; $input .= 'START %BROWSER% -new-tab '; $input .= '"'.$url.'"'; fwrite($handle, $input); fclose($handle); $command = "C:\\Windows\\System32\\wscript.exe I:\\emailchecker\\invisible.vbs "; $command .= $filename; echo $command; //execute bat exec($command); //($return_value == 0) or die("returned an error: $command"); sleep(5); unlink($filename); } this block is the function that I think is having the issue, if people are curious I can post the rest. Basically, when I run the whole script in CLI it's all working correctly. When I trigger it with an email through the pipe, it creates the .bat file, waits and then deletes it. But doesn't seem to actually run the script. Thoughts as to why exec (or system() that also) would work in CLI but not when triggered with the email; or at least thoughts regarding how to trace down the problem? Thanks Tom
  7. Related to that problem, given: $email = "Locations: King City"; $reg_exCity = '/Locations: (\w+) (\w+)?/'; preg_match($reg_exCity, $email, $city); echo $city[1]; echo $city[2]; returns KingCity $city1 = array_slice($city,1,2); echo $city1; returns Array I think I'm trying to use the correct function, but I'm obviously doing it wrong. Suggestions?
  8. I experimented with in_array() a little bit, but I still have the problem of turning an array with up to two values (ie a city name with two parts) into a single string... OR potentially rewriting my regex so that it will make $match[1] include both halves of the city name. Thoughts as to which is better or if one will even work?
  9. I'm trying to regex a city name from a string (an email that gets passed to the script) and then compare it to a text file so that I can cue an IF statement on whether or not it matches a city in the text file. I've got a regex that I think is correct, but I'm not sure how to pull the city name from the $matches and then load the list of cities and compare it. I've been messing with array_slice() and explode() and was starting to devolve into layers upon layers of preg_matchs so it seemed like it was time to ask for help. /*Get email contents from the piped email. I'm just plugging in the value in the form that it will come from the email so I don't have to send endless emails to myself to test */ //$email = file_get_contents('php://stdin'); $email = "Locations: King City"; //Regular expression to find the city name $reg_exCity = '/Locations: (\w+) (\w+)?/'; //Apply the city regex to the contents of the email preg_match($reg_exCity, $email, $city); //store city names in array $citiesArray = explode(",","cities.txt"); at this point I'm not even sure what the best way to compare the list to the value from the email will be. I guess another preg_match? //turn the name of the city into a regex $reg_exCities = '/'.$city[1].'/'.'i'; if (preg_match($reg_exCities, $citiesArray, $matches)) { echo "this one!"; } else { echo "not this one"; } Thanks for any help, it's been a while since I did much scripting, and I was never that great at it so this project is really making my brain stretch.
  10. Looks like I just need to go to bed. It appears to be an email-related issue. Either my gmail (that I was using to send test emails from) is limiting how fast I can send emails to one address or hmailserver isn't accepting emails from one address really quickly. Either way, not a PHP issue. Apologies and thanks for your patience. Tom
  11. I'm working on processing emails nearly instantaneously with a PHP CLI script that gets called by an email pipe. The email pipe is in hmail server. The script parses the email and then writes some bits into a text file. The problem I'm having is that if I send several emails in quick succession only the first one seems to interact with the script. The rest don't result in any behavior. I initially thought that my problem was with php's interaction with the text file so I tried writing some extra code to create a temp file and then copy it to the directory, but that doesn't seem to have changed the behavior at all so I'm wondering if it may be the email pipe that's the problem but I'm not sure how to go about tracking down the problem. Sorry for the run on sentences, it's been a long day. Here's my php: <?php //Get email contents when the server receives the email $email = file_get_contents('php://stdin'); //$email = "$395"; //Regular expression to find Value of the assignment $reg_exComp = '/\$(\d+)/'; //Apply the regex to the contents of the email and output to file preg_match($reg_exComp, $email, $comp); $i = 1; //Set the path and filename $filename = ("C:\\temp\\output".$i.".txt"); $dir = ("C:\\temp"); //if the file exists renumber the filename and rewrite the variable while(file_exists($filename)){ $i++; $filename = ("C:\\temp\\output".$i.".txt"); } //create the next highest filename and write to the file. $tmpfname = tempnam($dir, "tem"); $handle = fopen($tmpfname, "a"); fwrite($handle, $comp[1]); copy($tmpfname, $filename); fclose($handle); unlink($tmpfname); ?>
  12. I'm still having issues, but they aren't related to the problem with incrementing anymore so I guess I'll start a new thread with a new topic.
  13. I got it to do what (I think) I needed it to do: //Set the path and filename $filename = ("C:\\temp\\output".$i.".txt"); //if the file exists renumber the filename and rewrite the variable while(file_exists($filename)){ $i++; $filename = ("C:\\temp\\output".$i.".txt"); } //create the next highest filename and write to the file. $handle = fopen($filename, "a"); fwrite($handle, $comp[1]);
  14. are you sure while(!file_exists($filename)); is valid? I can't find any mention of using an exclamation point with a built-in function like that and it doesn't seem to be working for me (but I might just not be using it correctly.)
  15. I'm trying to figure out how to do this, or if there's a better way to do it, I'd be happy to hear it. Basically I'm creating a text (.bat) file as part of a PHP CLI script that is triggered by email piping on receipt of an email. The PHP script will parse the email for certain bits and then either create and activate the .bat file or just ignore it. (probably will log in to an email box and change the imap label of the email as another level of logging, but that's a future tribulation.) The worry that I had that I'm trying to guard against is multiple emails coming through near-simultaneously and overwriting the .bat file before it fires so I wanted to create a a function that will check for the existence of the file and if it exists, increment the file name. The problem I seem to be running in to is that I've already set the file path as the variable $filename and so it doesn't get incremented inside of $filename when I increment $i. The following is just a snippet that I was using to test the issue. $i = 1; $filename = ("C:\\temp\\output".$i.".txt"); do{ $i++; echo $filename;} while ($i<=5); Thanks Tom
×
×
  • 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.