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
https://forums.phpfreaks.com/topic/65234-web-form/
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
https://forums.phpfreaks.com/topic/65234-web-form/#findComment-325759
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
https://forums.phpfreaks.com/topic/65234-web-form/#findComment-325794
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
https://forums.phpfreaks.com/topic/65234-web-form/#findComment-325960
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.