May 3

Loja funksionon ne kete menyre :
Jepen disa fjale dhe scripti kerkon ne faqen www.picsearch.com , merr fotografite , i paraqet dhe i kerkon lojtarit te gjeje fjalen qe eshte perdorur per te marr ato fotografi.
Fjala ruhet ne session dhe vetem nese e gjen pergjigjen session fshihet dhe krijohet i ri me fjale te re….

Gabime ne kod : Loja nuk pranon fjale te ndara me hapesira (psh. : Ismail Kadare) , nese futet nje fjale e tille nxjerr gabim….rregullojeni :) , une do te perdorja str_replace…
DEMO : http://www.shtypidites.com/prova/loja.php

Kodi :

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
<?php
ob_start();
session_start();
$fjalet = array('shqiperia','sarande','kadare','internet','portokalli','parlamenti','gazeta','ferrari','nokia','linux');
if (!isset($_SESSION['loja'])) {$_SESSION['loja'] = $fjalet[rand(0,count($fjalet,COUNT_RECURSIVE))];}
$fj = $_SESSION['loja'];
$hap = file_get_contents('http://www.picsearch.com/search.cgi?q='.$fj.'&cols=5&thumbs=20');
$strip = strip_tags($hap,'<img>');
$kerko = preg_match_all("/<img width=(?:[^>]*) height=(?:[^>]*) src=\"(?:[^>]*)\" border=(?:[^>]*) hspace=(?:[^>]*) alt=\"Click to view image details\">/is", $strip, $rezultatet);
 
echo "
	Gjeni fjalen qe shprehet me keto fotografi...
<form action=''>
<input type='text' name='fjala'>
<input type='submit' name='shko' value='Kontrollo'>
	</form>
 
";
if (isset($_GET['shko'])) {
	if ($_GET['fjala'] == $fj) {
		echo " <font color='ff0000'><b>E GJETET</b></font> (Per 3 sekonda do te nderrohen fotografite...)";
		session_unset();
		header('Refresh: 3;url='.$_SERVER['PHP_SELF'].'');
        }else {
		echo " <font color='ff0000'><b>Nuk e gjetet ! Provoni perseri...</b></font>";
	}
}
$num= count($rezultatet,COUNT_RECURSIVE);
for ($i=0;$i<=$num;$i++) {
echo $rezultatet[0][$i]." ";
}
?>