
iamtom
Members-
Posts
10 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
iamtom's Achievements

Newbie (1/5)
0
Reputation
-
Best to copy all into notepad to make more sense.... file2.txt <?xml version='1.0'?> <rss version='2.0'> <channel> <language>en</language><title></title> <link>http://www.375fss.com</link> <description>The latest news and updates from military leisure-time travel.</description> <docs>Mytest.pdf</docs> <generator>Tom Rector Weekend Wonders</generator> <pubDate>Sun, 05 Sep 2010 10:38:30 -0600</pubDate> <item> </channel></rss> file1.txt (watch line wrap , only two lines here) <item><author>Your Friendly Scott Tavel Agent</author><title>Rams Tickets</title><description>Purchase any Rams home game ticket(s) from Information, Tickets & Travel and receive an equal number of tickets FREE for the Rams home opener vs. Arizona Cardinals on Sept. 12. A limited number of FREE tickets are available (excludes Arizona Cardinals). The free home opener tickets are terrace level with a $40 value. Tickets can be picked up at the Scott Club\'s Football Fanatics Tailgate Event held Sept. 9 from 4 to 6 p.m. at the Scott Club. Anyone who purchases Rams tickets will automatically be entered to win Rams Autographed Items (names to be drawn at Tailgate party). For complete details call </description><link>http://www.375fss.com/RSSdata.xml</link><pubDate>Sun, 05 Sep 2010 10:02:16 -0600</pubDate></item> <item><author>Your Friendly Scott Tavel Agent</author><title>Rams Tickets</title><description>Purchase any Rams home game ticket(s) from Information, Tickets & Travel and receive an equal number of tickets FREE for the Rams home opener vs. Arizona Cardinals on Sept. 12. A limited number of FREE tickets are available (excludes Arizona Cardinals). The free home opener tickets are terrace level with a $40 value. Tickets can be picked up at the Scott Club\'s Football Fanatics Tailgate Event held Sept. 9 from 4 to 6 p.m. at the Scott Club. Anyone who purchases Rams tickets will automatically be entered to win Rams Autographed Items (names to be drawn at Tailgate party). For complete details call </description><link>http://www.375fss.com/RSSdata.xml</link><pubDate>Sun, 05 Sep 2010 10:38:30 -0600</pubDate></item> Final file (desired outcome) <?xml version='1.0'?> <rss version='2.0'> <channel> <language>en</language><title></title> <link>http://www.375fss.com</link> <description>The latest news and updates from military leisure-time travel.</description> <docs>Mytest.pdf</docs> <generator>Tom Rector Weekend Wonders</generator> <pubDate>Sun, 05 Sep 2010 10:38:30 -0600</pubDate> <item><author>Your Friendly Scott Tavel Agent</author><title>Rams Tickets</title><description>Purchase any Rams home game ticket(s) from Information, Tickets & Travel and receive an equal number of tickets FREE for the Rams home opener vs. Arizona Cardinals on Sept. 12. A limited number of FREE tickets are available (excludes Arizona Cardinals). The free home opener tickets are terrace level with a $40 value. Tickets can be picked up at the Scott Club\'s Football Fanatics Tailgate Event held Sept. 9 from 4 to 6 p.m. at the Scott Club. Anyone who purchases Rams tickets will automatically be entered to win Rams Autographed Items (names to be drawn at Tailgate party). For complete details call </description><link>http://www.375fss.com/RSSdata.xml</link><pubDate>Sun, 05 Sep 2010 10:02:16 -0600</pubDate></item> <item><author>Your Friendly Scott Tavel Agent</author><title>Rams Tickets</title><description>Purchase any Rams home game ticket(s) from Information, Tickets & Travel and receive an equal number of tickets FREE for the Rams home opener vs. Arizona Cardinals on Sept. 12. A limited number of FREE tickets are available (excludes Arizona Cardinals). The free home opener tickets are terrace level with a $40 value. Tickets can be picked up at the Scott Club\'s Football Fanatics Tailgate Event held Sept. 9 from 4 to 6 p.m. at the Scott Club. Anyone who purchases Rams tickets will automatically be entered to win Rams Autographed Items (names to be drawn at Tailgate party). For complete details call </description><link>http://www.375fss.com/RSSdata.xml</link><pubDate>Sun, 05 Sep 2010 10:38:30 -0600</pubDate></item> </channel></rss>
-
Thanks ahead of time, I have been working this all week end but get lost.... a. I want to insert all the lines from file1.txt into file2.txt . b. I want the all lines in file1.txt to be inserted in file2.txt starting at "<image>" tag label in file2.txt. c. I would like to overwrite all lines that start with the "<image>" tag in file2.txt with the insert (text in file1.txt contains <image> tag also). file2.txt has lines above and below the insert point <image>. The insert text (file1.txt) could be as many as twenty lines (records) all/each beginning with the<image>tag. Here is what I have done so far. <? $key = '<image>'; //a text tag in $file1 and $file2 //copy file $file = "file1.txt"; $file2= 'file2.txt"; $newfile = "filetemp.txt"; copy($file, $newfile) or exit("could not copy $file"); //load file array $fc = fopen ($file, "r"); while (!feof ($fc)) { $buffer = fgets($fc, 4096); $lines[] = $buffer; } fclose ($fc); //open same file and use "w" to clear file ,not sure this is needed $f=fopen($newfile,"w") or die("$file did not open"); /* uncomment to debug print_r($lines); print "<br>\n"; */ //loop through array 'foreach foreach($lines as $line) { fwrite($f,$line); //rewrite $line in file if (strstr($line,$key)){ //find $key in each line fwrite($f,$newline."\n"); } //rewrite $line in file } fclose($f); copy($newfile, $file2) or exit("could not copy $newfile"); ?> Again thanks ahead of time, I just keep losing the flow, old I guess. Tom
-
Tried that... doesn't work inside script [[TODAY]] = 2010-02-14 (changed page to xxx.php) not html <template> <script> var name = "[[TODAY]] if (name <= "<?php $Today = date('Y-m-d'); echo $Today; ?>") { document.write("<td xxxxxxxxxxxxxxxxx>") } else { document.write("<td zzzzzzzzzzzzzzzzz>") } </script> </template> php does not supply the date when ran, is there a simpler way to do this?
-
Hello, Hope I am in the right forum.. I need to process to report a date., I am a roadside picnic guy, just put stuff together by example.... I have a flatfile database with a date field format of YYYY-MM-DD I run perl to list the records in a 'template' html page In this case, I use a java script to define the report look example: <html> <template> <script> var name = "[[DeadLine]]" if (name == "[[TODAY]]") { document.write("<td><!a href='http://www.XXXXXX.com/cgi-bin/ClassSignUp01.pl?CODE=[ ]&StartDate=[[startDate]]'>[[Title]]</a></td>") } else { document.write("<td><!a href='http://www.XXXXXX.com/cgi-bin/ClassSignUp0.pl?CODE=[[code]]&StartDate=[[startDate]]'>[[Title]]</a></td>") } </script> </template> </html> **<!a href=disabled**** [[TODAY]] needs to be the actual date of today so that classes past the DeadLine are shown diffferntly than classes that are still short of the DeadLine. So I need to be able to have today's date show in YYYY-MM-DD format at [[TODAY]] The mix of perl, html, java, and now a php process is nore than I can figure out. Thanks for the help !! Tom Any direction will be appreciated.
-
Don't know if this is new , probably not, but can't find exactly what I am looking for. I have a form that submits the field "name", to php script. The name field has full name in it, I want to select the last part of the name filed and create a new filed "LName". I don't know how to use explode, trim or preg to select data after a 'space' character. I tried this: (where Name is "xxxxx yyyyy") <?php //$arr = explode(' ',ltrim(rtrim($Name,''),'')); //$LName = $arr[1],true; ?> but it give me error codes for unexpected "," . I need just the yyyyy. Any help would be appreciated
-
Thnaks in advance for any pointers... I have a data filed that is 4 characters long, It is set to hold 4 numbers XXXX I and using it to hold the last 4 of credit card number , $last4 = substr($Ccrd, -4, 4); My problem is when any on the first characters are 0's it does not show them, so I get " 145" when I should get "0145". How can I prevent this and show the leading 0 ? Thanks Tom
-
This is kinda a second post,,,, My question is , how do I get the two peices of code below to work as one script? I am rather new to PHP and have been trying to figure out how to upload data and an image, then resize the image and save as a new image with the same piece of code. I can do it with multiple scripts, but I have been able to get the scripts intergrated to where I only use one script. I use Linux, Apache, and PHP 4.47. Both peices of code work individually. ///<?php include("global.inc.php"); $errors=0; $error="The following errors occured while processing your form input.<ul>"; pt_register('POST','DateRcvd'); pt_register('POST','status'); pt_register('POST','mgrName'); pt_register('POST','ItemDescr2'); pt_register('POST','ItemDescr'); pt_register('POST','Kcondition'); pt_register('POST','Kcomments'); pt_register('POST','Property'); pt_register('POST','Lot'); pt_register('POST','Value'); pt_register('POST','FMValue'); pt_register('POST','Quantity'); pt_register('POST','Fund'); pt_register('POST','Activity'); pt_register('POST','CostCtr'); pt_register('POST','Spare'); $Photo=$HTTP_POST_FILES['Photo']; pt_register('POST','ID'); if($HTTP_POST_FILES['Photo']['tmp_name']==""){ } else if(!is_uploaded_file($HTTP_POST_FILES['Photo']['tmp_name'])){ $error.="<li>The file, ".$HTTP_POST_FILES['Photo']['name'].", was not uploaded!"; $errors=1; } $DateRcvd = date("Y-m-d"); $ID = date("ymds"); $Lot = date("yd"); if($errors==1) echo $error; else{ $image_part = date("mds")."_".$HTTP_POST_FILES['Photo']['name']; $image_list[12] = $image_part; copy($HTTP_POST_FILES['Photo']['tmp_name'], "autoimages/".$image_part); $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/")); $message="DateRcvd: ".$DateRcvd." mgrName: ".$mgrName." ItemDescr: ".$ItemDescr." Kcondition: ".$Kcondition." Kcomments: ".$Kcomments." Property: ".$Property." Value: ".$Value." FMValue: ".$FMValue." Quantity: ".$Quantity." Fund: ".$Fund." Activity: ".$Activity." CostCtr: ".$CostCtr." Photo: ".$where_form_is."www.xxxxxxxx.com/IA/NEISO/autoimages/".$image_list[12]." ID: ".$ID." "; $message2= "Items requested for approval to sell at NAF Resale Store, click here for a Listing http://www.xxxxxxx.com/cgi-bin/NEISA.pl?status=Hold "; $message2 = stripslashes($message2); $message = stripslashes($message); mail("[email protected]","Request to Approve NAF Resale Items",$message2,"From: WebSite"); mail("[email protected]","(Copy)Request to Approve NAF Resale Items",$message,"From: WebSite"); $make=fopen("NEISOdata.dat","a"); $to_put=""; $to_put .= "|".$DateRcvd."|".$status."|".$mgrName."|".$ItemDescr."|".$ItemDescr2."|".$Kcondition."|".$Kcomments."|".$Property."|".$Lot."|".$Value."|".$FMValue."|".$Quantity."|".$Fund."|".$Activity."|".$CostCtr."|".$image_list[12]."|".$ID."|".$Spare."|" "; fwrite($make,$to_put); ?> <h2>Thank you!</h2> To add additional items from same cost center, <INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the previous page '> and change the appropriate info , then click Add Item. ?> Now for the second script, resizes images as they are uploaded and save a new image. ////<?php $uploadedfile = $_FILES['uploadfile']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); list($width,$height)=getimagesize($uploadedfile); $newwidth=400; $newheight=325; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = "images/s". $_FILES['uploadfile']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request ?> Thnaks to anyone that came show me how to make this one script.....
-
Yes, my question is how to make the two scripts work like one, so the image can be resized as it is loaded along with all the other required information... Thanks
-
Linux, Apache, PHP 4.4.7 Both scripts work fine independently I have two scripts, first one uploads data to a flatfile data database, including an image file reference and the actual image file. My problem is that I can't expect my users to resize their images, properly or consistantly. Many images are 600K to 1meg. I have another script that resizes images as they are loaded, allowing the user to upload any size image at 400x325 or whatever I set the parameters at. I know 400 x 325 is usually still over 200K but its a lot samller than the 600K I'm getting now. I then 'read' the datafile and display the info in html tables. The overall purpose is to creat a flatfile database for a second hand store, allowing 'customers' to see the items for sell, store is for active duty troops on a militray base. . Here is the code, I don't mean to create any issues so I will leave the fist line and the last two lines off so they don't appear actiive, and I have also xxxx'd out the domain. My idea is the have the second script included in the first script so that the image will be reized on fly as it is uploaded. Any help would be appreciated,,, this store is primarly used by lower rank troops, with less income. (1st script) include("global.inc.php"); $errors=0; $error="The following errors occured while processing your form input.<ul>"; pt_register('POST','DateRcvd'); pt_register('POST','status'); pt_register('POST','mgrName'); pt_register('POST','ItemDescr2'); pt_register('POST','ItemDescr'); pt_register('POST','Kcondition'); pt_register('POST','Kcomments'); pt_register('POST','Property'); pt_register('POST','Lot'); pt_register('POST','Value'); pt_register('POST','FMValue'); pt_register('POST','Quantity'); pt_register('POST','Fund'); pt_register('POST','Activity'); pt_register('POST','CostCtr'); pt_register('POST','Spare'); $Photo=$HTTP_POST_FILES['Photo']; pt_register('POST','ID'); if($HTTP_POST_FILES['Photo']['tmp_name']==""){ } else if(!is_uploaded_file($HTTP_POST_FILES['Photo']['tmp_name'])){ $error.="<li>The file, ".$HTTP_POST_FILES['Photo']['name'].", was not uploaded!"; $errors=1; } $DateRcvd = date("Y-m-d"); $ID = date("ymds"); $Lot = date("yd"); if($errors==1) echo $error; else{ $image_part = date("mds")."_".$HTTP_POST_FILES['Photo']['name']; $image_list[12] = $image_part; copy($HTTP_POST_FILES['Photo']['tmp_name'], "autoimages/".$image_part); $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/")); $message="DateRcvd: ".$DateRcvd." mgrName: ".$mgrName." ItemDescr: ".$ItemDescr." Kcondition: ".$Kcondition." Kcomments: ".$Kcomments." Property: ".$Property." Value: ".$Value." FMValue: ".$FMValue." Quantity: ".$Quantity." Fund: ".$Fund." Activity: ".$Activity." CostCtr: ".$CostCtr." Photo: ".$where_form_is."www.xxxxxxxx.com/IA/NEISO/autoimages/".$image_list[12]." ID: ".$ID." "; $message2= "Items requested for approval to sell at NAF Resale Store, click here for a Listing http://www.xxxxxxx.com/cgi-bin/NEISA.pl?status=Hold "; $message2 = stripslashes($message2); $message = stripslashes($message); mail("[email protected]","Request to Approve NAF Resale Items",$message2,"From: WebSite"); mail("[email protected]","(Copy)Request to Approve NAF Resale Items",$message,"From: WebSite"); $make=fopen("NEISOdata.dat","a"); $to_put=""; $to_put .= "|".$DateRcvd."|".$status."|".$mgrName."|".$ItemDescr."|".$ItemDescr2."|".$Kcondition."|".$Kcomments."|".$Property."|".$Lot."|".$Value."|".$FMValue."|".$Quantity."|".$Fund."|".$Activity."|".$CostCtr."|".$image_list[12]."|".$ID."|".$Spare."|" "; fwrite($make,$to_put); ?> <!-- This is the content of the Thank you page, be careful while changing it --> <h2>Thank you!</h2> To add additional items from same cost center, <INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the previous page '> and change the appropriate info , then click Add Item. Now for the second script, resizes images as they are uploaded. // This is the temporary file created by PHP $uploadedfile = $_FILES['uploadfile']['tmp_name']; // Create an Image from it so we can do the resize $src = imagecreatefromjpeg($uploadedfile); // Capture the original size of the uploaded image list($width,$height)=getimagesize($uploadedfile); // For our purposes, I have resized the image to be // 400 pixels wide, and maintain the original aspect // ratio. This prevents the image from being "stretched" // or "squashed". If you prefer some max width other than // 400, simply change the $newwidth variable $newwidth=400; $newheight=325; $tmp=imagecreatetruecolor($newwidth,$newheight); // this line actually does the image resizing, copying from the original // image into the $tmp image imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // now write the resized image to disk. I have assumed that you want the // resized, uploaded image file to reside in the ./images subdirectory. $filename = "images/". $_FILES['uploadfile']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request // has completed.