Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

The impossible html file

Okay I'm certified in html and this one still boggles me and haunts me at night.  

Okay i am making a site for a client and one for myself and i ran into the same problem.

Now when making a form to submit data to a remote source (supposing they dont filter it (using the post action) you just use action whatever.php

what if your making a script like me where im (trying) to create a script that will mass unsubscribe users from newsletters and other unwanted junk mail (my list of cgi's and php url's to submit to is about 300) and to make a button for each seems foolhardy,  so i suppose that my question is this,  how would i (with one button) submit that same email address to the abovementioned remove sections... with a single click.

I need to write a (preferably) client side program to do this. javascript vbscript and plain old html.  for server side you could use cgi or possibly php.... im fluent in all but i cannot seem to get multiple functions and variables into 1 form.

~sarevok9~
0
sarevok9
Asked:
sarevok9
  • 4
  • 2
  • 2
1 Solution
 
WitchazelCommented:
well, not sure best way but you make an iframe and loop thru posting in it

if you are using jscript you can create the iframes on the fly too and post them

then you can here that nice redirect click sound 300 times :)

-w
0
 
ZontarCommented:
I would definitely use a serverside script for this.

IN PHP you can use fsockopen() and fputs() to send a HTTP POST or GET to a script.

Before the script can be written, you must know what the exact requirements are for each email-removal script are:

1. complete URL of the script
2. required fieldname(s)/value(s)
3. submission method (GET or POST)

Do you have this info already available in an easy-to-read format such as a comma-delimited text file or a database table?

I will assume that:

1. each script requires only a single field/value (the email address to be removed)
2. the info for each removal script is stored in a text file named "remove-scripts.txt" in the following format:

url, method, fieldname

one entry per line, no skipped lines. for example:

"www.site1.com/cgi-bin/remove-me.cgi", "POST", "email"
"site2.net/removeit.asp", "GET", "email"
"www2.site3.com/", "POST", "user"
"removals.site4.net/removeme.php", "GET", "u"
"site5.net/email/delete-email.php.", "POST", "e"
"www.site6.com/email/management/unsub.asp", "POST", "email"

etc.

Source of mass-remove.php. Warning: I am doing no error-checkiung whatsoever in this script.

<html>
<head></head>
<body>
<?php
if( isset($_POST["email"]) )
{
  $email = $_POST["email"];

  $fp = fopen( realpath("remove-scripts.txt") );

  while( !eof($fp) )
  {
    $line = fgets($fp);
    list($url, $method, $field) = each( explode(",", $line) );

    $domain = substr($url, 0, strpos("/", $url));
    $path = strstr($url, "/");

    $data = $field . "=" . urlencode($email);
    $response = "";

    $fs = fsockopen($domain, 80, &$errno, &$errstr, 120);

    if($method == "POST")
    {
      fputs($fs, "POST $path HTTP/1.1\r\n");
      fputs($fs, "Content-type: application/x-www-form-urlencoded\r\n");
      fputs($fs, "Content-length: " . strlen($data) . "\r\n\r\n" );
      fputs( $fp, "$data\r\n\r\n" );
    }
    else
      fputs($fs, "GET $path?$data HTTP/1.1")

    while( !feof($fs) )
      $response .= fgets( $fp, 1024 );

    echo "<pre>$response</pre>";
    fclose($fs);
  }
 
  fclose( $fp );
}
else
{
?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">
<p>Your email: <input type="text" name="email"></p>
<p><input type="submit" value="Unsubscribe Me"></p>
</form>
<?php
}
?>
</body>
</html>

This may not be 100% accurate, as I've just dashed it off the top of my head, but it should serve to give you a fair idea of what needs to be done.

An article you may find helpful: http://www.zend.com/zend/spotlight/mimocsumissions.php
0
 
ZontarCommented:
WH, I also thought about using JS and an iframe, but decided it would be too unwieldy/unreliable.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
WitchazelCommented:
i definately agree with zontar,  while it would be possible to do client side (hafta be ie to be close to stable), server side will make your life much easier :)

if you only need to to post a few forms, iframe would be great, 300 is gonna go poof.

if you just need to hit the url of the pages, you could loop thru and load them in javascript, but if you need to post you will still have problems.
(e.g.  http://www.badspammers.com/unsubscribe.html?email=witch@hazel.com)

-w
0
 
ZontarCommented:
> hafta be ie to be close to stable

What causes you to make this (IMO unwarranted) assumption?
0
 
sarevok9Author Commented:
in my own expirence a lot of server side includes (regardless of language) are left out by mozilla and netscape communicator,  however navigator and mozilla firebird work well except when it comes to external css.... which they occ. hiccup on
0
 
sarevok9Author Commented:
Zontar if you error check that and make it a working script you got the points and a extra 250.
~s9~
0
 
ZontarCommented:
> in my own expirence a lot of server side includes (regardless of language) are left out by mozilla and netscape communicator,  however navigator and mozilla firebird work well except when it comes to external css.... which they occ. hiccup on

This is a server issue, not a browser issue, since browsers don't "see" include files, only what the include files send to the browser. If the SSIs generates valid (not just "looks okay in MSIE") HTML, there's no problem. CSS "hiccups" are caused by servers that send CSS as the wrong mimetype -- many servers it as plaintext or text/html whereas the correct type is text/css. (MSIE assumes that a .css extension = CSS. This may sound convenient, but it's NOT a good idea.) Add the correct mimetype to your server config and the problem will go away.

For Apache, just add

AddType text/css .css

to your .htaccess file or make the corresponding change to the master Apache config file. For IIS, you'll need to add the type in IIS Manager.

>  Zontar if you error check that and make it a working script you got the points and a extra 250.

Give me some sample data for testing.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now