
mihomes
Members-
Posts
17 -
Joined
-
Last visited
Never
Everything posted by mihomes
-
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.
-
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...
-
Like I said, I didn't write it...
-
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); } } ?>
-
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.
-
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; ;?>
-
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.
-
No, I am not sending in html - rather I want to send in plain/text as I noted in the op.
-
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.
-
Can't insert tab into text file - just won't show!
mihomes replied to mihomes's topic in PHP Coding Help
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. -
Can't insert tab into text file - just won't show!
mihomes replied to mihomes's topic in PHP Coding Help
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. -
Can't insert tab into text file - just won't show!
mihomes replied to mihomes's topic in PHP Coding Help
Anyone? This is driving me nuts -
Can't insert tab into text file - just won't show!
mihomes replied to mihomes's topic in PHP Coding Help
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. -
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); }
-
Comments on the below please. Basically this should send out the correct headers to tell if it should retrieve a new version of the page or use the cached version (it has the current). top of every page goes : [code]<?php include($_SERVER['DOCUMENT_ROOT']."/cache.php");?> // sends the gmt last modified date <?php doConditionalGet(gmdate("D, d M Y H:i:s", filemtime($_SERVER['SCRIPT_FILENAME'])) . " GMT");;?>[/code] in cache.php is : [code]<?php //--------------------------------- // doConditionalGet function definition //--------------------------------- function doConditionalGet($timestamp) { // Create ETag from last modified date $etag = '"'.md5($timestamp).'"'; // Send the headers header("Last-Modified: $timestamp"); header("ETag: $etag"); header('Expires: '.gmdate('D, d M Y H:i:s', strtotime('+1 month')).' GMT'); // If browser provided IMS and ETag, get them // Otherwise, set variable to 'false' $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false; $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false; if (!$if_modified_since && !$if_none_match) { return; } // If at least one value exists, validate them if ($if_none_match && $if_none_match != $etag) { return; // ETag exists but doesn't match } if ($if_modified_since && $if_modified_since != $timestamp) { return; // IMS exists but doesn't match } // Nothing has changed since last request // Return a 304 and do NOT run the rest of page header('HTTP/1.1 304 Not Modified'); exit; } ?>[/code] Everything appears to work fine, however, I suspect the expires tag is wrong. Currently it sends the current date/time plus one month. This SHOULD be one month after the last modifed date. What would the correct code to replace this so it is '$timestamp + one month'? $timestamp in its current form would be something such as 'Wed, 27 Dec 2006 07:15:07 GMT'. Is there any easy way to just add one month to it?
-
Here is the deal... I just switched all my websites to a new server and they are all on the same IP address whereas before each site had its own IP. I make a call such as <?php include($_SERVER['DOCUMENT_ROOT']."/document.php");?> What I expect from this is it will look at www.example.com/document.php as it always did before. Instead it looks for the 'document.php' file from the first account on the IP. Warning: main(/home/absolute/public_html/document.php): failed to open stream: No such file or directory in /home/network/public_html/index.html on line 1 Warning: main(): Failed opening '/home/absolute/public_html/document.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/network/public_html/index.html on line 1 So in this case it should look for the file in the account network, but instead looks for it in the account absolute as all the domains are on the same IP now. How in the world can I fix this? I cannot change the code to <?php include($_DOCUMENT_ROOT."document.php");?> as if the call is made in a higher directory then the root it looks in the wrong location.