Software, your way.
burger menu icon
WillMaster

Will Bontrager Blogs Website Techniques

WillMasterBlog > PHP

Formatting CSV

"CSV" stands for "Comma-Separated Values". CSV is a popular plain text format often used especially for exporting and importing data to and from various spreadsheet software.

This article is for PHP programmers. I'll show you how to format CSV with PHP.

Do it with a function. Here is one that will do the trick.

function MakeCSVline($array)
{
   $formattedarray = array();
   foreach( $array as $chunk )
   {
      if( preg_match('/[\"\'\r\n\,]/',$chunk) )
      {
         $s = str_replace('"','""',$chunk);
         $formattedarray[] = '"' . $s . '"';
      }
      else { $formattedarray[] = $chunk; }
   }
   return implode(',',$formattedarray);
} # function MakeCSVline()

In a PHP script, call the function with an array of values. The function returns a line of CSV-formatted text.

Here is an example.

<?php
$testarray = array( 'chocolate', 'Tom "Smiley" Thumb', 'The fortune, the freedom' );
$CSVline = MakeCSVline($testarray);
echo $CSVline;
function MakeCSVline($array)
{
   $formattedarray = array();
   foreach( $array as $chunk )
   {
      if( preg_match('/[\"\'\r\n\,]/',$chunk) )
      {
         $s = str_replace('"','""',$chunk);
         $formattedarray[] = '"' . $s . '"';
      }
      else { $formattedarray[] = $chunk; }
   }
   return implode(',',$formattedarray);
} # function MakeCSVline()
?>

The example script turns this array:

Array
(
    [0] => chocolate
    [1] => Tom "Smiley" Thumb
    [2] => The fortune, the freedom
)

Into this CSV line:

chocolate,"Tom ""Smiley"" Thumb","The fortune, the freedom" 

The MakeCSVline() function handles multi-line values as well as values that contain quotation marks or commas.

The CSV-creating function is a handy little tool for you PHP programmers.

(This content first appeared in Possibilities newsletter.)


WillMasterBlog > Content Protection

Link Security Considerations

Even on a secure web page, tapping a link can result in compromised information.

There are two ways data is insecure even when you are viewing a secure web page with the browser's lock icon closed.

  1. The URL in the browser's address bar is visible and not encrypted. Therefore, if the URL contains any information for the destination web page, the information will not be secure.

    Here is an example URL with information:

    https://example.com/page.php?person=Will&email=will@example.com
    
  2. The server log that records the arrival of a browser at the destination web page will record the URL. If the URL contains any information, it will be recorded in the log.

    For an example URL with information, see the previous list item.

The above example requests the destination web page with method GET, which is the method generally used when a link is tapped.

When the destination web page is requested with method POST instead of method GET, both of the above insecurities are eliminated.

  1. With method POST, the URL in the browser's address bar contains only the protocol and domain name. With an SSL connection, any information is sent securely to the destination web page.

  2. With method POST, only the protocol and domain name are recorded in the server log. Any information sent to the destination web page is not recorded in the server log.

Tapping a link to another web page generally is method GET. Submitting a form generally is method POST.

The Willmaster.com library's Posting Links article describes how to make links that submit method POST. A link with information that must be secure when tapped can be made with the information described in that article.

Usually, links don't need to be secure, even when they contain additional information. But when the information must not be compromised, sending it method POST is the prudent thing to do.

(This content first appeared in Possibilities newsletter.)


WillMasterBlog > HTML

Audio Tag for Music Streams

The audio tag can be used to listen to live audio streams directly from the source. Putting the tag on your own web page makes it available from any device or computer with a browser.

All audio stream websites I've seen (music streams, mostly) offer a browser-based app to listen to their music. But there is one drawback to that, you have to change web pages if you want to listen to another site's stream.

With your own web page, it can have an audio tag for every one of your favorite streams. There is no need to send your browser to a different web page.

With more than one audio tag on your own web page, and one already playing, 2 clicks changes the stream.

  1. Tap the "stop" icon of the stream you want to stop.

  2. Tap the "start" icon of the new stream.

(If you start a new stream without stopping the other, you'll hear both streams.)

Here is an audio tag to play music from Easy Hits Florida, a classic rock music stream.

Here is the source code for the above Easy Hits Florida stream audio tag.

<audio controls src="https://das-edge11-live365-dal03.cdnstream.com/a80304"></audio>

To listen to a different stream, change the src value to the new stream's URL.

How to Get Audio Stream URLs

Some audio streaming websites provide their stream URLs, in addition to their app. For others, it may work to use the browser's "view source code" menu item to find the audio tag and copy the src URL.

The streamurl.link/ website can be used to help find streaming URLs you can't locate on the stream-source websites. (Their "Stream URL" icon puts the URL onto your clipboard ready for pasting.) Caveat: Many of their audio stream URLs point to locations no longer available. Test the URLs.

Another way is to use an AI chat bot to find streaming URLs. A prompt something like "provide the audio-stream URL for WCRB 99.5 radio station to use in an HTML audio tag's src value" might work. This also comes with the caveat that URLs provided by the AI might no longer be available.

Of course, a person could do the obvious, use the website's contact form and ask for the URL.

Making Your Own Audio Streams Web Page

In essence, this is a regular web page. The content of the web page is an audio tag for each of your favorite streams. For clarity, the name of each stream can be published with its audio tag.

Consider putting your web page at a location with an HTTP URL instead of HTTPS. The reason is so you have a larger selection of streams to choose from. Some audio stream URLs have only HTTP URLs. The browser might complain if you put an audio tag with an HTTP URL on an HTTPS page.

Others may find your web page of audio streams. If they listen to the streams, the resources are provided by their browser and the stream source server, not by your server. In other words, the audio streams do not go through your server.

If your audio streams web page contains confidential information, it may be prudent to put it in an access-restricted directory.

Most of the music I listen to while I am working is through my own web page of audio tags. It's quick and simple to change stations whenever I feel like it.

Now you know how to make your own.

(This content first appeared in Possibilities newsletter.)


WillMasterBlog > Misc

A Quarter of a Century

The very first issue of Possibilities (known as "Willmaster Possibilities" at that time) was published on July 27, 1999. It has been published every week since.

This issue marks the 25th anniversary.

This is issue #1304. There were 1,304 weeks in those 25 years. 7 of them were leap years.

If you are interested, here are the calcuations to determine the number of weeks between two dates (using "52 weeks per year" doesn't work for anything more than 3 years).

365 × 25 years = 9125 days.
Plus 7 leap year days = 9132.
9132 ÷ 7 = integer 1304 weeks.
Weekly 25 years = issue # 1304.

The "How Many Weeks Between Dates?" demo can be used for determining the number of weeks between 2 dates. For verifying the above calculation, the start date is July 27, 1999 and the the 25th anniversary is July 27, 2024.

To celebrate, or to cuddle up to nostalgia, the very first issue of this newsletter is reproduced further below.

The only URL in that first issue that has survived 25 years is http://willmaster.com/possibilities/. The other URLs, every email address, and the postal address are all invalid today. Several names have been altered to protect the folks from learning, suddenly, that 25 years later their name is published again. Placeholders between double square brackets are for the emailing software to insert personalization.

Enjoy the nostalgic feeling. (Tap here for easier reading. Phones will display better in landscape position.)

NOTES:

Your personal subscription information with removal 
     instructions is below this newsletter.

If you wish to forward this newsletter to friends and/or 
     associates, please forward the entire newsletter. 
     You may, however, delete your subscription information.

BEGIN NEWSLETTER:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      W i l l M a s t e r     P o s s i b i l i t i e s

                 Nice site! What does it do?

July 27, 1999                                      Issue # 1
William Bontrager, Publisher -- possibilities@willmaster.com
                        http://willmaster.com/possibilities/
Copyright (c) 1999 by William Bontrager.All rights reserved.
============================================================

[[name]], this is a personalized publication. 
If your name is incorrect, please send an email to 
mailto:name-possibilities@willmaster.com and specify the 
spelling and capitalization of the name you prefer for 
your personalized copy of WillMaster Possibilities.

Your name is also key to extending our anti-spam 
protection to you when you contribute copy to WillMaster 
Possibilities. Our technology allows us to use one common 
email address in conjunction with a unique code which 
forwards your personal email to your real address. See 
"How to use the anti-spam features".

==============================



Contents:   

   ~-~ Prelude
   ~-~ Possibility: Spam Proofing Your Websites
   ~-~ Q&A
   ~-~ Forum: E-zine Personalization
   ~-~ Guiding Quote of the Week
   ~-~ Subscribers Talk Back
   ~-~ How to use the anti-spam features
   ~-~ Newsletter addresses and URLs

Articles in the works for future issues:
     Determining Your Visitor's Time Zone.
     Letting Visitors Recommend Your Website.
     Letting Visitors Email a Web Page To Themselves.
     Providing a Printer-Friendly Web Page for Visitors.
Special issue, "How To Hire a CGI Programmer", coming soon.

==============================
                       Advertisement

Your answering machine is on-line!        30-day FREE TRIAL
                      No more missed calls.
        Fast download!                    30-day FREE TRIAL
                   Pagoo Communications, Inc.
Free Download: http://willmaster.com/a/pagoo.pl 

==============================



~-~ Prelude

Hello [[name]],

What is your reaction to personalized newsletters? The
"Forum: E-zine Personalization" section, below, addresses 
that question. Please voice your opinion; state your 
feelings about it. Thank you.

Welcome to the premier issue of "WillMaster Possibilities".

Many internet professionals are so busy with other aspects 
of their sites -- design, marketing, copy writing -- there 
is little time left to pursue the technical details which 
make websites more than static presentations.

The focus of WillMaster Possibilities is to present things 
your website can *do*, primarily by using established, 
proven technology. Some issues may speculate about emerging 
methods or internet-related inventions. Mostly, though, you 
will find useful techniques which allow your websites to 
interact with your visitors.

This premier issue uses the most familiar CGI application 
on the internet and gives it an additional purpose.

William Bontrager
Publisher

==============================



~-~ Possibility:

                   Spam Proofing Your Websites

Visitor feedback forms have been around ever since browsers 
have supported CGI.

They're on most professional sites. Certainly they are on 
those sites which best project friendly customer service.

Today, we'll use the feedback form to help spam proof your 
sites.

Spammer's email harvesting robots scan your site for email 
addresses. Then the addresses become part of spammers' 
mailing lists.

Here is a practical way to remove all email addresses from 
your site. And whether or not your sites have access to 
their own CGI.

(Spammers collect email addresses from other sources, too. 
Spam proofing sites removes only one source.)

[[name]], I'm on a mission.

I don't like spammers harvesting email addresses from 
our sites. Uninvited, demanding our time and stealing 
our resources to sate their greed by pushing their 
impatience-soaked ideas into our faces. And I don't 
like them doing it to our friends.

So, I decided to do something about it.

The result is MasterFeedback, a visitor feedback form and 
Perl CGI script. The form contains no email addresses in 
the HTML code or on the page, not even in a hidden form 
field.

The script is freely available for download, along with 
a generic HTML form you can modify. This free version is 
for Unix servers. (Find download URL further below.)

There is also a version for:

   ~ folks who don't have CGI for their sites.
   ~ web sites on NT or other non-Unix operating systems.
   ~ folks who don't want to mess with scripts but still 
     want the benefits.

This second version requires sign-up and a monthly fee.

While I was making MasterFeedback, Mari Bontrager made 
graphical buttons with our email addresses as images. 
These will be our links to the feedback forms.

[[name]], spam proofing your sites 
is a simple two-step process:

(1) Obtain a feedback form.

(2) Eliminate all email addresses and replace them with 
    links to your feedback forms.

That's it!


STEP: (1) Obtain a feedback form.

This means you either acquire and install a script for 
that purpose, or you use a script hosted on someone else's 
server.

MasterFeedback is robust and does the job quite well. But 
it's not the only tool around.


~~ If you have CGI:

MasterFeedback (free) (Unix) is available for download at: 
http://willmaster.com/MasterFeedback/ 

There are dozens of free and shareware feedback scripts. 
They're available for all popular operating systems -- 
Unix, NT, Linux. Some CGI download sites are listed in the 
"Links and Resources" section of:
http://willmaster.com/possibilities/examples.html 

Whichever script you decide to use, please make sure it 
does not require your email address anywhere within your 
web page, not even in hidden form fields.


~~ If you do not have CGI (or just don't want to be 
   bothered with it):

Remote hosted CGI is your solution. This means the forms 
are on your server (on your web site), but the script is 
on someone else's server.

Remote hosted MasterFeedback is designed so your visitors 
never need to leave your site. They stay with you, even 
when they click the submit button. The service is only 
$2 per month. Sign up for your 14-day free trial at 
http://willmaster.com/c/ 


STEP: (2) Eliminate all email addresses and replace them 
          with links to your feedback forms.

(For illustration purposes, let's suppose your feedback 
form is at "http://www.domain.com/feedback.html" and that 
your email address is "name@domain.com".)

Replace all occurrences of:

<a href="mailto:name@domain.com">Write Me!</a> 

with:

<a href="http://www.domain.com/feedback.html">Write Me!</a> 

If you want a graphic link, just replace "Write Me!" (or 
other link text) with your graphic's "<IMG ..." tag. 

A simple graphic with your email address as the image can 
present your address visually and yet not have the text 
anywhere in your source code. Spammers are not yet 
sophisticated enough to make graphic image reading robots.

(Note to users of AOL and HTML email readers: The above 
contains HTML code examples. If your reader shows them 
as links (or doesn't show them at all), you may need to 
view the source code in order to reveal the HTML code in 
its entirety.)

One more note: To spam proof your sites, no text with an 
email address can be in your page source code, anywhere. 
Not in image "alt" tags, no in META tags, not in html 
comment areas, nowhere. You may wish to use your word 
processor or page editor's search function to ensure no 
stray "@" characters with email addresses remain on your 
pages.

That's all there is to it, [[name]].

Happy spammer swatting!

William Bontrager, Programmer and Publisher
"Screaming Hot CGI" programs
"WillMaster Possibilities" e-Newsletter
http://willmaster.com/possibilities/ 
mailto:relay@willmaster.com?Subject=|William| 
Copyright (c) 1999 by William Bontrager

Permission is granted to reprint the above article in its 
entirety provided no changes are made to the article and 
the author's name, signature lines, and copyright line are 
printed with the article;
except
   ~ you may remove the personalizations, and
   ~ you may change the article's title.
To obtain a reprintable copy of this article with the 
personalizations already removed for you, visit:
http://willmaster.com/possibilities/archives/ 

==============================
                       Advertisement

An answering machine on your PC!          30-day FREE TRIAL
        No more missed calls while you are on-line.
                Fast download!            30-day FREE TRIAL
                        Pagoo Communications, Inc.
Free Download: http://willmaster.com/a/pagoo.pl 

==============================



~-~ Q&A

(The procedure for submitting questions is below.)

This premier issue has only one question.

Debbie Author of Debbie Author Creations, publisher of 
the "AC Designer" and maintainer of a wonderful ezine 
directory, asks:

      Is there a universal way to protect scripts from 
      hackers? I was "horrified" to find out that hackers 
      can access passwords etc. through the script.

      Is there a line of code that I can put in each script 
      to alleviate this problem (besides @referrer)?

      Debbie Author
      Debbie Author Creations
      http://www.debbieauthorcreations.com
      mailto:relay@willmaster.com?Subject=|Deborah|

(The "@referrer" Ms. Author refers to is a technique which 
limits use of a CGI program to forms at specific URLs.)

Yes, there are things you can do. But there really is no 
cure-all; even the United States Pentagon computers are 
known to have been cracked into.

(1)
Prevent browsers from getting directory listings.

Put an index page into your vulnerable directories. The 
index page could bounce (redirect) the person to your 
home page or other URL. You will find a ready-made, quite 
speedy, bouncer template in the "Other References" section 
of http://willmaster.com/possibilities/examples.html Just 
replace the example URLs with your own and upload it to 
your server.

(2)
If you have access to it, employ your server's security 
features. Unix with Apache can restrict CGI programs and 
scripts to specific methods of data acquisition. NT and 
Linux may have similar features.

See the "Other References" section of 
http://willmaster.com/possibilities/examples.html for a 
few technical details, of various skill levels, for 
modifying CGI programs and scripts so they will function 
within restricted data acquisition methods.

The referenced page also talks about work-arounds which 
allow a script to trap and either reject or modify 
hazardous characters related to shell commands and 
server side includes.

(3)
http://www.mcp.com/ has many on-line books which you can 
"check out" for free. Some of their books are about server 
security. Once there, click on "Personal Bookshelf".

                -----     -----     -----

Wondering about something?

Got a burning question?

Now is the time to ask!

Pick the programmer's brains.

Questions about websites, what is possible to do with them, 
and how to interact with your visitors.

To submit items for the "Q&A" section:
mailto:QandA-possibilities@willmaster.com
All contributors to Q&A are protected by Master Anti-Spam 
Technology (MAST).

==============================



~-~ Forum:

                   E-zine Personalization

You have seen several instances of personalization in this 
newsletter.

Like it? Don't like it?

Too much? Not enough?

Pleasant? Too familiar?

Now that you've had a chance to consult your feelings about 
this, please write and let me know. If you do not wish to 
participate in this public forum, you may write to me 
privately at mailto:relay@willmaster.com?Subject=|William| 

As a publisher, I like the idea of personalizing WillMaster 
Possibilities for my subscribers. It lets me feel as if I'm 
letting you know, at least in part, how much you are 
appreciated.

As a programmer, I like the challenge of writing the code. 
WillMaster Possibilities is mailed to you by a list server 
being built for that purpose. It will evolve as different 
needs and preferences come to light.

As a subscriber to a goodly number of ezines and discussion 
lists, I receive a few publications which are personalized 
in a limited manner. The first personalized mass publication 
I received, I felt somewhat offended. "How dare they," I 
though, "pretend to know me personally. I know I'm just a 
name on a list. They can't fool me!"

I wear many hats. And sometimes the impetus of one hinders 
another. Your views, as a subscriber, will be closely 
considered and taken into account when deciding the future 
course of WillMaster Possibilities and the software which 
delivers it.

To participate in this Forum, send your contribution to:
mailto:forum-possibilities@willmaster.com?Subject=|P-eZines|
Ensure the "Subject:" contains the Forum Topic.
All participants in this forum are protected by Master 
Anti-Spam Technology (MAST).

==============================



~-~ Guiding Quote of the Week

Our next door neighbor, regarding learning new tasks on her 
computer:

"If it takes more than two clicks, I can do without."
[Anne Brown]
mailto:relay@willmaster.com?Subject=|AnneBrown| 

Question: Would Anne Brown successfully navigate your site?

==============================



~-~ Subscribers Talk Back

Share your views. This is where ideas and opinions are 
the coin of the realm.

Got a special joy or an injustice you want to air?

Continuing discussions will have their own Forum Topic.

To submit items for "Subscribers Talk Back":
mailto:talk-possibilities@willmaster.com
(Your email may begin a new Forum Topic)
All contributors to "Talk Back" are protected by Master 
Anti-Spam Technology (MAST).

==============================



~-~ Newsletter addresses and URLs

Sending your emails to the applicable address will 
facilitate responding to your communication. Thank you.

To subscribe, send a blank email to:
            mailto:subscribe-possibilities@willmaster.com

To unsubscribe, send a blank email to:
            mailto:unsubscribe-possibilities@willmaster.com

"Q&A" submission:
            mailto:QandA-possibilities@willmaster.com

"Subscribers Talk Back" submission:
            mailto:talk-possibilities@willmaster.com
            (Your email may begin a new Forum Topic)

"Forum" submission (type the Forum Topic as the subject of 
your email):
            mailto:forum-possibilities@willmaster.com

Other newsletter related email: 
            mailto:possibilities@willmaster.com

Online issues (and reprints for your publication): 
            http://willmaster.com/possibilities/archives/

Personal email to William Bontrager: 
            mailto:relay@willmaster.com?Subject=|William|

William Bontrager, Publisher
Rural Route 1
Box 271-B
Solsberry, IN 47459
USA
mailto:possibilities@willmaster.com
http://willmaster.com/possibilities/
Copyright (c) 1999 by William Bontrager.All rights reserved.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:END NEWSLETTER

Your personal subscription information:

name: [[name]]
Email: [[email]]
Subscription Request Date: [[USdate]]
Subscription Source: [[referrer]]
To remove your information, send a blank email to:
remove-possibilities@willmaster.com 
mailto:remove-possibilities@willmaster.com 

I hope you experienced a smile while scanning through that issue.

As you know after reading through the first Possibilities issue, for decades I have had my attention on preventing spam.

Virtually all forms we offer to the public have spam-prevention considerations.

My Spam-free Form is a relatively easy web-page form to implement. Give it a try. Probably the form uses the most effective anti-spam method on the internet (no form tags). The form has been used on websites for over 5 years. I am aware of no automated spam report in all that time.

(This content first appeared in Possibilities newsletter.)


How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC