<?php
		/* 		developed by webous agency 
				http://www.webous.com 	
				author: val petruchek
				e-mail: val@webous.com
				date: 	March 30, 2005								*/

if (!empty($_POST))
	{
	$user = $_POST['user'];
	$pass = $_POST['pass'];

	$ns = fsockopen($_POST['server'],$_POST['port']);
	if (!$ns) 
		die("Can not connect to $server:$port");	
	$s = fgets($ns,1024);
    fputs($ns,"user $user\n");
	$s = fgets($ns,1024);
    fputs($ns,"pass $pass\n");
	$s = fgets($ns,1024);
	if (substr($s,0,3)!="+OK")
		die("Invalid username/password");
    fputs($ns,"stat\n");
	$s = fgets($ns,1024);
	list (,$total,) = explode(' ',$s);
	if (!$total)
		{
	    fputs($ns,"quit\n");
		die("No messages in the mailbox");
		}
	$deleted = 0;
	for ($i=1;$i<=$total;$i++)
		{
	    fputs($ns,"dele $i\n");
		$deleted++;
		}
    fputs($ns,"quit\n");
	echo "Messages deleted: <b>$deleted</b><br>";
	}
?>
<html>
	<head>
		<title>POP3 cleaner</title>
		<style>
			body,td,div,p,a,input,textarea,select
				{
				font-family: Verdana, Georgia;
				font-size:	8pt;
				color: black;
				}
			a {text-decoration:none;color:Red}
			a:hover {text-decoration:underline;color:black}
			.red {color:red}
			input.ainp{BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, Sans-serif; BACKGROUND-COLOR: #ffffff ; font-size: 10px; color: #000000; border-color : #727272; height:18px}
			input.asubm{BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; FONT-FAMILY: Verdana, Helvetica, Sans-serif; font-size: 8pt; color: #000000; background-color : #3B62BA; color:white; font-weight:bold; border-color:antiquewhite;cursor:hand}
			.bold {font-weight:bold}
			textarea{BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, Sans-serif; BACKGROUND-COLOR: #ffffff ; font-size: 10px; color: #000000; border-color : black;overflow : auto;}
		</style>
<body bgcolor=white>
<form name=a method=post action="<?=$_SERVER['PHP_SELF']?>">
<center>
Server: <input class=ainp type=text size=50 name=server><br><br>
Port: <input class=ainp type=text size=10 name=port value="110"><br><br>
Username: <input class=ainp type=text size=50 name=user><br><br>
Password: <input class=ainp type=text size=50 name=pass><br>
<br>&nbsp;<br>
<input type=submit value="clean the mailbox" class=asubm>
</form>
</center>
<p align=right style="color:gray"><a href="http://webous.com/free-scripts/pop3-cleaner/" style="color:gray">pop3 cleaner script</a> by <a href="http://webous.com/" style="color:gray">custom php cms development</a> at webous.com</p>
</body>
<html>
