Jump to content

Web form


itisme

Recommended Posts

My buddy sent me a php script to extract MD5 hashes from a text file. I can see the references for hashes.txt however I am unsure how to  submit. Ideally I would like to use an HTML forum to submit txt file.

 

I have to parts to the script:

 

1:

 

<?php
// sunjester
//  - Email address removed from bots quote post to view -
// www.hgsdomination.com
function strip_md5($str){
    $words = 0;
    $str = eregi_replace(" +", " ", $str);
    $array = explode(" ", $str);
    for($i=0;$i < count($array);$i++)
 {
        if (eregi("[0-9A-Za-zÀ-ÖØ-öø-ÿ]", $array[$i])) 
	$words++;
	$checklen = strlen($array[$i]);
	if($checklen == "32") {
	echo $array[$i]."<br>";
	}
    }
    return $words;
}
?>

 

 

and 2.

 

<?php
$filename = "hashes.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$test = $contents;
echo strip_md5($test)." words available<hr>";
echo strip_md5($test)." words available<hr>";
?>

 

Any help would be greatly appreciated

Link to comment
Share on other sites

I guess you mean that you want to post the MD5 stuff in a web form instead of needing to edit the text file... although sending even md5s of stuff over the web is not too secure, there are md5 crackers out there... but here's what I'd do:

 

<?php
if($_POST['text'] != "") {
  $contents = strip_tags($_POST['text']);
  $test = $contents;
  echo strip_md5($test)." words available<hr>";
  echo strip_md5($test)." words available<hr>";
} else {
  // Print the form...
  echo "<form action='thisPage.php' method='post'><textarea rows='20' cols='30' name='text'>";
  echo "</textarea><input type='submit' value='DO MD5 Stuff!' /></form>";
}

// sunjester
//  - Email address removed from bots quote post to view -
// www.hgsdomination.com
function strip_md5($str){
    $words = 0;
    $str = eregi_replace(" +", " ", $str);
    $array = explode(" ", $str);
    for($i=0;$i < count($array);$i++)
 {
        if (eregi("[0-9A-Za-zÀ-ÖØ-öø-ÿ]", $array[$i])) 
	$words++;
	$checklen = strlen($array[$i]);
	if($checklen == "32") {
	echo $array[$i]."<br>";
	}
    }
    return $words;
}
?>

 

Try this (and change the 'thisPage.php' to the name of your script...)

Hope that helps.

Link to comment
Share on other sites

Try this (sorry its long but i think it's what you want):

In "upload.html":

<form enctype="multipart/form-data" action="upload_2.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" /> <!-- 10MB -->
File: <input name="userfile" type="file" /><br />
<center><input type="submit" value="Upload" /></center>
</form>

 

Then in "upload2.php":

<?php
$name = $_FILES['userfile']['name'];
$size = $_FILES['userfile']['size'];
$type = $_FILES['userfile']['type'];
if(!uploadFile($name,"theFolderYouWantTheFileIn")) die("The file couldn't be uploaded. Please contact your network administrator.");

$filename = "theFolderYouWantTheFileIn/".$name;
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$test = $contents;
echo strip_md5($test)." words available<hr>";
echo strip_md5($test)." words available<hr>";

function uploadFile($name,$folder) {
  $filename=$_FILES['userfile']['name']; 
  $filesize=$_FILES['userfile']['size']; 
  $tempname=$_FILES['userfile']['tmp_name']; 
  $fullname=$folder."/".$filename;
  copy($tempname, $fullname) or return false; 
  return true; 
}

function strip_md5($str){
    $words = 0;
    $str = eregi_replace(" +", " ", $str);
    $array = explode(" ", $str);
    for($i=0;$i < count($array);$i++)
 {
        if (eregi("[0-9A-Za-zÀ-ÖØ-öø-ÿ]", $array[$i])) 
	$words++;
	$checklen = strlen($array[$i]);
	if($checklen == "32") {
	echo $array[$i]."<br>";
	}
    }
    return $words;
}
?>

 

Hope that helps.

Link to comment
Share on other sites

Thanks, that exactly what I'm looking for. I get the following error while trying to upload file:

 

Parse error: parse error, unexpected T_RETURN in /var/www/html/12/upload_2.php on line 20

 

and line 20 is:

copy($tempname, $fullname) or return false; 

 

any ideas?

Link to comment
Share on other sites

Try replacing the function with

function uploadFile($name,$folder) {
  $filename=$_FILES['userfile']['name']; 
  $filesize=$_FILES['userfile']['size']; 
  $tempname=$_FILES['userfile']['tmp_name']; 
  $fullname=$folder."/".$filename;
  copy($tempname, $fullname) or die("Cannot upload file!"); 
  return true; 
}

Post back if that doesn't work...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.