-
Notifications
You must be signed in to change notification settings - Fork 0
/
two.php
85 lines (64 loc) · 8.73 KB
/
two.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php //if user has clicked the Post button and text is available, start analysis
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['text2'])){
//create an array of words.
$words=explode(' ',$_POST['text2']);
$repl=array('');
//remove all punctuation marks eg ,:
foreach ($words as $s){
$repl[]=str_replace(array(',','.',';',':','"','(',')'),'',strtolower($s));
}
sort($repl);
//arrays to hold unique words and unique counts
$unique_words=array('');$unique_counts=array('');
//create new array of unique words and count how many times they appear
foreach ($repl as $s){
//replace carriage return
$words2=explode('\n\r',$s);
foreach ($words2 as $x){
if(array_count_values($unique_words)[$x]==0){
$unique_words[]=$x;$unique_counts[]=array_count_values($repl)[$x];
}
}
}
//print out xml doc of analysis
header('Content-type: text/xml');header('Pragma: public');header('Cache-control: private');header('Expires: -1');echo '<?xml version="1.0" encoding="utf-8"?><xml>';$index=0;
foreach ($unique_words as $s){
echo'<uniqueword><word>'.$s.'</word><count>'.$unique_counts[$index].'</count></uniqueword>';
$index++;
}
echo '</xml>';return;
}?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>EatOut - Kenya</title>
<link href="https://fonts.googleapis.com/css?family=Lobster|Raleway" rel="stylesheet">
<style type="text/css">body{font-family: 'Raleway', sans-serif;}a{text-decoration:none;border-radius:5px;display:block;padding:20px;width:100px;color:#fff;background:#2b71b1;}body>div{color:#000;background:#ebeced;max-width:960px;width:960px;margin-left:auto;margin-right:auto;padding:50px;margin:100px;border:solid 1px #441111;border-radius:5px}textarea{width:800px;height:300px;padding:5px}input{margin-top:10px;color:#fff;border:none;border-radius:5px;display:block;padding:10px 50px;background:#8892BF}</style>
</head>
<body><div><p>This Solution Counts The Number Of Times A Word Appears In The Provided Text.</p>
<p>Please Click The Post Button Below To Analyse The Document</p>
<p>Document 2</p><form action="two.php" accept-charset="utf-8" method="post" ><textarea name="text2">Caius was grabbed from his bunk and pulled out of the tent into the dark of night. With a hood over his face, he could only hear the thwunk sounds of a helicopter coming closer. He felt the wind begin to pick up, swirling around his bare skin, as he hadn't even been allowed an opportunity to dress. As soon as it landed, he was dragged aboard, and it took off again.
His hood was removed. He sat before a man in formal white robes, who sat in silence studying him. The dull red lights that lit the back of the helicopter gave him a devilish appearance. He tapped his fingertips together as he soaked in every inch of Caius' appearance.
"Caius, I'm afraid that I have very little time to bring you up to speed. I am your advocate," the man said without introducing himself. "Do you know what that is?"
"Sir," Caius barked, "An advocate is one who speaks for the accused in court, Sir."
"Excellent military form, Caius. This will be a big plus when reviewing you. But I'm talking about a very special type of advocate, Caius. You have been accused of no crime. Rather, you are up for a promotion, let's say. And I will be the one to speak for your qualities."
Caius nodded slowly. The swaying helicopter made him sick. Looking out the window, he could see the dawn breaking over the sea, with the islands of Japan disappearing in the distance. They were bringing him back to the mainland for something.
"Caius, you have had a peculiar life so far, haven't you? Born to wealthy parents who died suddenly and mysteriously? Educated at the finest schools, orphaned without a penny to your name, apprenticed to an engineer, and now a soldier?"
Caius affirmed without question.
"Have you ever wondered why your peers never experienced such turmoil?"
Caius paused, then replied emotionless: "Sir, I wonder that every day."
"Well, Caius," the advocate said, "They have never had your troubles because they were never candidates. You have been bred from birth to lead the Empire. Your genetic makeup was hand-picked by the Emperor himself, in consultation with the greatest scientists. You were given every advantage as a child, to weed out those who would become indolent and lazy with wealth. And you must remember what every citizen strives for. You were sent to the finest schools, with the most difficult subjects, to weed out those without the intellect to run the empire. And you must remember that research and science is the heart of a strong empire. You had everything taken from you, cast out into the streets, to weed out those who would not retain their compassion. And you must never forget to take care of those who have the least. You were apprenticed, to weed out those who could not work hard and put in effort. And you must always know the plight of the working man. Finally, you were trained in the military, to weed out those who would not make a good solider or leader. And as emperor, you must know the horrors or war before sending your own men to fight."
Caius sat silent, like a stone pillar.
"Cauis, you are one of the few remaining candidates. Your last trial shall be before the Senate Tribunal. Your every move, throughout all these years of your life, has been taped and recorded. Every moment of weakness or instance of misbehavior. And there is a team of inquisitors now delving into the depths of your mind, trying to find any weakness in this evidence. I will advocate for you, but they will advocate against you. If you are better than the other candidates, you will be crowned Emperor."
"Sir," Caius started, hesitant. "I do not understand. Should the new emperor not be the son of the current emperor?"
"Technically, you are!" the advocate answered. "As I said, you were born and bred from your first moment to fill this role. The emperor donated his own sperm, and you were conceived through in-vitro fertilization and implanted an an acceptable host. You see, The empire suffered for centuries through wars of succession and strife, as each distant relative of every emperor tried to prove their worth as soon as the old emperor died. It practically tore us apart, many different times. Eventually, Emperor Creiphus decreed in 1341 that succession would no longer be determined by who had the largest army, but who passed the trial of the Senate Tribunal, thus continuing Rome's long history of Democracy. Creiphus also resumed the use of the title "First Citizen" officially, though subjects still referred to him (and every successor since) as emperor."
"Over the years, we have gotten more and more detailed. At first, we simply voted on the candidates as soon as the old emperor died. But in the 1700s, great Senate leaders decreed that we must not just vet candidates, but actually shape them. And so the trials began, where the descendants of the emperor were put through tests to determine their worth. We began the tests earlier and earlier, taking babes from their mothers and raising them in different circumstances to test their mettle. As our technology has improved, we've been able to improve their physical and intellectual capabilities, and improve our monitoring."
Caius nodded slowly.
"Of course, none of this is public information," the advocate said with a short laugh. "To the citizens, the emperor is flawless, and so are his heirs. The children are conceived in secret, and the public is never told of their identities until the emperor is ready to announce his heir. The public never learns of the many rejected heirs."
"Why is that," Caius asked. "Don't they speak about the trials after they have been rejected?"
"Don't worry about that for now," the advocate said, staring off into the distance of the Asian mainland. "We'll cross that bridge if we have to."
The advocate walked to a cabinet on the other side of the helicopter's compartment. He pulled out a formal suit and tossed it to Caius. "Put this on," he said. "You'll need to be more presentable for the Senate Tribunal." He reached back into the cupboard and pulled out stacks of books and binders. "And we have two days for you to get caught up on the current events of the empire; the Tribunal will quiz you on what you would do in each situation, and any number of hypotheticals." Reaching into the cupboard one last time, he pulled out a ceremonial, gold-plated sword and a standard military-issue rifle. "And of course, the trials of combat."
With a grimace, Caius accepted the load of materials and went to work. Less than an hour ago, he'd never thought of what it would be like to be emperor. Now, he was determined to be crowned or die trying.</textarea><input type="submit" value="Post"></form></div>
</body>
</html>