Jump to content

mihomes

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mihomes's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Played around with it today... a view path variables were wrong that I fixed and everything is working smoothly. At some point though I am going to clean up the code, but for now it is working correctly.
  2. well I am the only person who has it - a friend wrote it for me years and years ago - its not like its for sale or anything so I wouldnt consider it a third party...
  3. Like I said, I didn't write it...
  4. Someone wrote this script for me ages ago - works fine on php4, but having some issues with php5 and the installation & reflect changes files... In a nutshell it takes a file called state.txt (all 50 states one per line) and creates a directory for each. There is then a text file for each state, for instance Alabama.txt, which has all the cities of that state. You end up with a directory for each state with directories of each city within them. Header and footer files as well as an index.php are used for each level. Trying to use this it creates the directores for each state, but does so in the root folder rather than the actual location of the file on the particular site. I realize $_SERVER['PATH_TRANSLATED'] has been removed, but replacing this with $_SERVER['SCRIPT_FILENAME'] doesn't seem to correct the issue. install.php <?php set_time_limit(0) ; $arr = explode("/",$_SERVER['PATH_TRANSLATED']); $ct = count($arr); unset($arr[$ct-1]); $path=implode("/",$arr); $path=$path."/"; if(is_file($path."state.txt")) { $lines = file($path."state.txt"); if($lines) { foreach($lines as $line) { if($line) { $state = trim($line); if(!is_dir($state)) { @mkdir($state,0777); if(is_file($path."copieble/state/index.php")) { $from = $path."copieble/state/index.php"; $to = $path.$state."/index.php"; @copy($from,$to); } } } } } } @chdir($path); $handle=opendir('.'); while (($file = readdir($handle))!==false) { @chdir($path); if (($file != ".") && ($file != "..")) { if(is_dir($file) && $file != "copieble" && $file !="_vti_cnf") { if(is_file($path.$file.".txt")) { $lines = file($path.$file.".txt"); if($lines) { foreach($lines as $line) { if($line) { $city = trim($line); @chdir($path.$file); if(!is_dir($city)) { @mkdir($city,0777); if(is_file($path."copieble/city/index.php")) { $from = $path."copieble/city/index.php"; $to = $path.$file."/".$city."/index.php"; @copy($from,$to); } } } } } } } } } closedir($handle); include("reflect_changes.php"); ?> reflect_changes.php <?php $arr = explode("/",$_SERVER['PATH_TRANSLATED']); $ct = count($arr); unset($arr[$ct-1]); $path=implode("/",$arr); $filepath=$path."/copieble/state/index.php"; //print_r($_SERVER); // Copy here the index file for all the states folder if(is_file($filepath)) { chdir($path); //echo "<br>".$path."/state"; $handle=opendir('.'); while (($file = readdir($handle))!==false) { if (($file != ".") && ($file != "..")) { if (is_dir($file) && $file !="copieble" && $file !="_vti_cnf") { $dst = $path."/".$file."/index.php"; @copy($filepath,$dst); } } } closedir($handle); } // Copy here the index file for all the cities in each states $filepath = $path."/copieble/city/index.php"; if(is_file($filepath)) { if(is_dir($path)) { chdir($path); //echo "<br>".$path."/state"; $handle=opendir('.'); while (($file = readdir($handle))!==false) { if (($file != ".") && ($file != "..")) { if (is_dir($file) && $file != "copieble" && $file !="_vti_cnf") { chdir($path."/".$file); $handle1=opendir('.'); while (($file1 = readdir($handle1))!==false) { if (($file1 != ".") && ($file1 != "..")) { if (is_dir($file1)) { $dst = $path."/".$file."/".$file1."/index.php"; @copy($filepath,$dst); } } } closedir($handle1); } chdir($path); } } closedir($handle); } } ?>
  5. Yes, I'm aware of that - this whole thing was bcause I don't want to send html content in the emails. Well, guess I'll just stick to what I have.
  6. Not the prettiest, but it does the job the way I am given the contents... I did this in html so I could test it. Only thing left is to string replace the original part with $new. Although, I just realized that this whole thing is pointless without using a fixed width font :-\ haha so really wont serve the purpose in a plain/text email. preg_match('/<!-- BEGIN CARTITEMS -->(.+)<!-- END CARTITEMS -->/si', $message, $match); $match = explode("|",$match[0]); $count = 0; $new .= "<font face='Courier'>"; while ($count < count($match)-1){ $count++; $new .= str_pad($match[$count++], 10, " ", STR_PAD_LEFT); $new .= str_pad($match[$count++], 15, " ", STR_PAD_LEFT); $new .= str_pad($match[$count++], 50, " ", STR_PAD_LEFT); $new .= str_pad($match[$count++], 20, " ", STR_PAD_LEFT); $new .= str_pad($match[$count++], 20, " ", STR_PAD_LEFT); $new .= "<br>"; } $new .= "</font>"; echo $new; ;?>
  7. That's kinda of what I am leaning for - as of now I am just inserting spaces, but of course, nothing is aligned. The part that is getting me is grabbing just that section out of the variable.
  8. No, I am not sending in html - rather I want to send in plain/text as I noted in the op.
  9. Okay, this email is basically an order confirmation email which contains cart contents that is sent to me and the customer. I prefer to send the emails in plain/text so there are no html issues and it is cleaner. Here is an example of the email sent : Date: Wed Dec 31, 2008 10:41 am Invoice ID: 5B92BBD94 Coupon: hohoho IP: 111.111.111.111 <!-- BEGIN CARTITEMS --> 2 W4556 Blue Widgets $62.55 $125.10 <!-- BEGIN CARTITEMS --> 1 f4578f Red Widgets $109.35 $109.35 <!-- BEGIN CARTITEMS --> 1 d45789 Green Widgets $166.05 $166.05 <!-- END CARTITEMS --> Out of stock items (these will ship separately at no additional charge when.... and so on The above comes to me in the form of a variable $message and then is sent to myself and the customer in an email. What I want to do is align the cart items in columns. I attempted to do this with tabs, however, I noticed not all email clients insert the tabs (such as outlook express) even when sent in plain/text format. So, what I think I need to do is use str_pad for each of the items. Removing the tag lines <!-- is no problem at all and can be done with str_replace. How the heck can I go about aligning the items though? There is qty, id, desc, price, and total for each cart item. I'm thinking if I use str_pad somehow for each I can insert a certain number of whitespaces for each by knowing the longest possible string length of each column. I do not even need to figure this out as I know already what these are. So... any help on this. I am pretty quick when it comes to coding, but not familiar with php, what functions are available, or how to go about this. Any help would be really appreciated.
  10. Well, after doing some more research it turns out the tabs are inserted its just outlook express is deciding not to show them unless I specifically tell it to read all emails in plain/text through the options. So, I think str_pad would be a good way to go here as far as aligning these products. Now, I am not all too familiar with php, but I get the gist of it pretty good... I just don't know any of the function names and what to look for, for what I want to do. Here is an example order email and what I am thinking : Date: Wed Dec 31, 2008 10:41 am Invoice ID: 5B92BBD94 Coupon: hohoho IP: 111.111.111.111 <!-- BEGIN CARTITEMS --> 2 W1245 Widget 5 BLUE $62.55 $125.10 <!-- BEGIN CARTITEMS --> 3 W4859 Widget 34 RED $9.00 $27.00 <!-- END CARTITEMS --> Out of stock items (these will ship separately at no additional charge when they become available): NONE Customer Comments: and so on....... The above is stored as $message before sending the email to myself. Basically all I need to do here is use str_pad for each of the variables - qty, id, desc, price, total - on each line until <!-- END CARTITEMS --> is reached. So, in other words read in each one, insert the correct str_pad, go to next and so on... when everything is done I can use str_replace to remove the <!-- BEGIN CARTIEM --> and <!-- END CARTITEM -->. Result would be $message with the cart contents aligned nicely with certain whitespaces to the left thus aligning all the cart items in the email. Any help on this one or is there an easier way? I can also add in delimiters before each cart variable if that would make it easier.
  11. Well, there are columns - qty, id, name, price, total for any number of product which the customer is ordering. Using tabs would make it somewhat easier to align them in a plain/text email. I guess I am going to have to write a function to align everything using spaces.
  12. I don't think thats the case. I can respond to the email which isnt showing tabs (goes back to another email account of mine) and then receive it on the same email client and it will show the tabs wherever I enter them. I viewed properties as well and it is text/plain format just like the one I sent.
  13. In the below code I am sending myself an email in plain/text (a customer order to be exact). $message comes in as plain text as shown here with the %%variables%% being replaced with their actual values before being sent to the function: Date: %%ORDERDATE%% Invoice ID: %%INVOICE%% Coupon: %%COUPON%% IP: %%IP%% <!-- BEGIN CARTITEMS --> %%QUANTITY%%***%%PRODUCTCODE%%***%%NAME%%***%%PRICE%%***%%TOTAL%% <!-- END CARTITEMS --> Out of stock items (these will ship separately at no additional charge when they become available): NONE Customer Comments: %%COMMENTS%% Subtotal: %%SUBTOTAL%% Discount: -%%DISCOUNT%% (Coupon '%%COUPON%%') Shipping: %%TOTALSHIPPING%% Total: %%GRANDTOTAL%% Ship to / Project Location: %%FIRSTNAME%% %%LASTNAME%% (%%EMAIL%%) %%COMPANY%% %%ADDRESS%% %%ADDRESS2%% %%CITY%%, %%STATE%% %%ZIP%% %%PHONE%% Thank you for your quote request. If the..... Now, in the function I am sending myself the email. I use string replace to remove the '<!-- BEGIN CARTITEMS -->' and '<!-- END CARTITEMS -->' lines because if I don't then every product is surrounded by them. That works absolutely fine and all products end up listed one per line in the email. The problem is adding in a tab. I use the same string replace and replace every * with \t. It removes the *'s, but there is no tab inserted whatsoever. If I switch the code to \n then it works and gives new lines for each *. For whatever reason I cannot get a tab inserted. What am I doing wrong!? function SendPHPMail($sendtoemail, $from, $fromemail, $additional, $subject, $message, $html){ $eol="\n"; $headers = "MIME-Version: 1.0".$eol; $headers .= "Content-type: text/plain; charset=utf-8".$eol; $headers .= "From: $from <$fromemail>".$eol; $headers .= "Reply-To: $from <$fromemail>".$eol; if ($additional != ""){ $additional = explode(',',$additional); foreach($additional as $value) $headers .= "Cc: $value".$eol; } $remove1 = "<!-- BEGIN CARTITEMS -->\n"; $remove2 = "<!-- END CARTITEMS -->\n"; $ast = "*"; $message = str_replace($remove1, '', $message); $message = str_replace($remove2, '', $message); $message = str_replace($ast, "\t", $message); $success = mail($sendtoemail, $subject, $message, $headers); }
×
×
  • 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.