PHP Classes
elePHPant
Icontem

File: wordcounter.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Parminder Singh  >  Words counter  >  wordcounter.php  >  Download  
File: wordcounter.php
Role: Example script
Content type: text/plain
Description: words counter
Class: Words counter
Search and count words in a file
Author: By
Last change: $file=$_FILES["filename"]["temp_name"]; is change with $file=$_FILES["filename"]["name"];
Date: 5 years ago
Size: 1,724 bytes
 

Contents

Class file image Download
<?php
 
include_once("class.wordcounter.php");
 
ini_set('display_errors', 0);
 
?>
<html>
<head>
<script type="text/javascript" language="javascript">
function validate()
{
if(document.getElementById('filename').value=='')
{
document.getElementById('result').innerHTML='File Is Required';
 return false;
 }


}
</script>

</head>
<body>
<h1>Words Counter</h1>
<form action='' method=post enctype='multipart/form-data' onSubmit="return validate()" >
File to Upload <input type='file' name='filename' id="filename"><div id="result" style=" float:left; color:#CC0000; font-weight:bold"></div>
<input type='hidden' name='action' value='upload'>
<br/>Search any word <input type="text" name="search" /><br/>
<input type="radio" value=0 name="casecheck" />Case Senstive <input type="radio" value=1 name="casecheck" checked="checked" />Non Case Senstive
<br/>
Show List <input type="checkbox" name="list" /> <input type="radio" value=0 name="orderby" checked="checked" />Ascending <input type="radio" value=1 name="orderby" />Descending
<input type='submit' value='Upload File' name="submit">

</form>
</body>
</html>
<?php

   
if ($_FILES["filename"]["size"] ) ;
    {
   
   
copy($_FILES["filename"]["tmp_name"],"./".$_FILES["filename"]["name"]) or die("<b>File Required!</b>");
    }
    echo
"<b>File Uploaded.</b>"; // for debug --> $filename --> ".$destination."/".$filename_name."</h2>";
   
$file=$_FILES["filename"]["name"];
$search=$_REQUEST['search'];
$casecheck=$_REQUEST['casecheck'];
$list=$_REQUEST['list'];
$orderby=$_REQUEST['orderby'];

$wc = new WordCounter($file,$casecheck);
$wc->searchWord($search,$casecheck);
if(isset(
$list))
{
$wc->checkOrder($orderby);
}
?>