0)
{
if(trim($_GET['searchterm']) == "")
{
$message = '
Alphabet-Only for Search function!
';
}
else
{
echo "Search Term: " . trim($_GET['searchterm']) . "
";
$search_input = trim($_GET['searchterm']);
if(preg_match('/^[A-Z]+$/i', trim($search_input)))
{
echo "Valid! Alphabet Only!
";
$lines = file("posts.txt");
$posted_array = array();
$counter = 0;
foreach ($lines as $key => $line) {
$posted_array[$key] = $line;
$words = explode("|", $line);
$each_posted_array = array();
// echo '$lines['.$key.'] = ' . $line . "
";
foreach ($words as $key => $word) {
$word = trim($word);
$each_posted_array[$key] = $word;
if( count($each_posted_array) == 7 )
{
for ($i=0; $i < 7; $i++) {
// echo '$each_posted_array['.$i.'] = ' . $each_posted_array[$i] . "
";
if($i == 3) // do validation
{
// echo "comment: " . $each_posted_array[3] . "
";
if(preg_match('/^loremPPP/i', trim($each_posted_array[3])))
{
echo "[TEST TEST TEST leremPPP]
Valid!Valid!Valid!Valid!Valid!
Valid!Valid!Valid!Valid!Valid!Valid!
";
}
else // if(preg_match('/^loremPPP/i', trim($each_posted_array[3])))
{
$pos = strpos(trim($each_posted_array[3]), $search_input);
// if($pos == true)
if(preg_match('/'.$search_input.'/i', trim($each_posted_array[3])))
{
echo "FOUND! FOUND! FOUND! FOUND! " . "
";
/*
echo "first name: " . $each_posted_array[0] . "
";
echo "last name: " . $each_posted_array[1] . "
";
echo "title name: " . $each_posted_array[2] . "
";
echo "time name: " . $each_posted_array[6] . "
";
echo "priority: " . $each_posted_array[4] . "
";
*/
if($each_posted_array[4] == 1)
{
$array_result1[0] = $each_posted_array[0];
$array_result1[1] = $each_posted_array[1];
$array_result1[2] = $each_posted_array[2];
$array_result1[4] = $each_posted_array[4];
$array_result1[6] = $each_posted_array[6];
}
elseif($each_posted_array[4] == 2)
{
$array_result2[0] = $each_posted_array[0];
$array_result2[1] = $each_posted_array[1];
$array_result2[2] = $each_posted_array[2];
$array_result2[4] = $each_posted_array[4];
$array_result2[6] = $each_posted_array[6];
}
elseif($each_posted_array[4] == 3)
{
$array_result3[0] = $each_posted_array[0];
$array_result3[1] = $each_posted_array[1];
$array_result3[2] = $each_posted_array[2];
$array_result3[4] = $each_posted_array[4];
$array_result3[6] = $each_posted_array[6];
}
else
{
$array_result3[0] = $each_posted_array[0];
$array_result3[1] = $each_posted_array[1];
$array_result3[2] = $each_posted_array[2];
$array_result3[4] = $each_posted_array[4];
$array_result3[6] = $each_posted_array[6];
}
$array_result = array_merge($array_result1, $array_result2);
$array_result = array_merge($array_result, $array_result3);
echo "count elements in total: " . count($array_result) . "
";
}
else
{
echo "NOT FOUND! NOT FOUND! NOT FOUND! NOT FOUND! " . "
";
}
} // if(preg_match('/^loremPPP/i', trim($each_posted_array[3])))
}
}
// echo "counter: " . $counter ."
";
$counter++;
}
} // foreach ($words as $key => $word) {
} // foreach ($comment_posts_lines as $key => $value) { // outside foreach loop
}
else // if(preg_match('/^[a-z_]+$/i', trim($search_input)))
{
echo "invalid";
} // if(preg_match('/^[a-z_]+$/i', trim($search_input)))
}
}
else
{
// echo "no count for get method.";
} // if(count($_GET) > 0)
?>
COMP 3015
Results
| Name |
Title |
Time |
$value) {
?>
|
|
|
$value) {
?>
$value) {
?>
|
|
|
$value) {
?>
$value) {
?>
|
|
|
$value) {
?>