'a', 'Á' => '1', 'B' => 'b','C' => 'c','D' => 'd','Ð' => '2', 'E' => 'e', 'É' => '3', 'F' => 'f','G' => 'g','H' => 'h','I' => 'i','Í' => '7','J' => 'j','K' => 'k','L' => 'l', 'M' => 'm','N' => 'n','O' => 'o','Ó' => '4','P' => 'p','Q' => 'q','R' => 'r','S' => 's', 'T' => 't','U' => 'u','Ú' => '5','V' => 'v','W' => 'w','X' => 'x','Y' => 'y','Ý' => '6','Þ' => '8','Æ' => '9','Ö' => '0','Z' => 'z'); session_start (); ?> Hardkjarni Online
 

Leikir

 

 

Leikir

getMessage()); $res = $db->query('select max(id) from '.$dtable); if (DB::isError($res)) die ($res->getMessage()); $numero_parole = $res->fetchRow(); $posizione_parola = rand (2, $numero_parole[0]); $res = $db->query('select id, word from '.$dtable.' where id = '.$posizione_parola); $parola = $res->fetchRow(); $db->disconnect(); return ($parola); } // check if the player can be added to the top list function ControllaRecord ($user, $pword, $dhost, $dbase, $dtable, $wordid, $tempo, $tentativi) { $chk = array(false); require_once ('DB.php'); $dsn = "mysql://$user:$pword@$dhost/$dbase"; $db = DB::connect($dsn, true); if (DB::isError($db)) die ($db->getMessage()); $res = $db->query('select * from '.$dtable.' where id = '.$wordid); if (DB::isError($res)) die ($res->getMessage()); $riga = $res->fetchRow(); if ($tentativi<$riga[3] or ($tentativi==$riga[3] and $tempo<$riga[4])) $chk[0] = true; if ($riga[3]==6) $riga[2]='*nuovo**'; $chk[1] = $riga[2]; $chk[2] = $riga[3]; $chk[3] = $riga[4]; return $chk; } // read the actual best score function CercaRecord ($user, $pword, $dhost, $dbase, $dtable, $wordid) { require_once ('DB.php'); $dsn = "mysql://$user:$pword@$dhost/$dbase"; $db = DB::connect($dsn, true); if (DB::isError($db)) die ($db->getMessage()); $res = $db->query('select best, errors, time from '.$dtable.' where id = '.$wordid); if (DB::isError($res)) die ($res->getMessage()); $riga = $res->fetchRow(); return $riga; } // changes all the unguessed letters with _ function CalcolaIndovinata ($parola, $escludi, $alfabeto) { $alfabeto = array_flip ($alfabeto); $escluse = strtr ($escludi, $alfabeto); $escluse = '['.$escluse.']'; $escluse = ereg_replace ($escluse, '', '[AÁBCDÐEÉFGHIÍJKLMNOÓPQRSTUÚVWXYÝZÞÆÖ]'); $indovinata = ereg_replace ($escluse, '_', $parola); return $indovinata; } // seeks the chosen letter in the word function TrovaLettera ($lettera, $parola, $scelte, $alfabeto) { $alfabeto = array_flip ($alfabeto); $lettera = substr ($lettera, 0, 1); $lettera = strtr ($lettera, $alfabeto); $scelte.= $lettera; if (ereg ($lettera, $parola)) { $controllo = true; } else { $controllo = false; } $risposta = array ($scelte, $controllo); return $risposta; } // and this is the programme! // the word to be guessed has already been chosen if (isset($_GET['letter']) and isset($_SESSION['gchangman'])) { $variab = explode ('/', $_SESSION['gchangman']); $indovina = $variab[0]; $scelte = $variab[1]; $tentativi = $variab[2]; $checklet = TrovaLettera ($_GET['letter'], $indovina, $scelte, $alfabeto); $scelte = $checklet[0]; if (!$checklet[1]) { $tentativi = $tentativi +1; } $indovinata = CalcolaIndovinata ($indovina, $scelte, $alfabeto); } else { // reset everything and choose a new word $tentativi=0; $scelte = ('_'); $parola = ScegliParola ($user, $pword, $dhost, $dbase, $dtable); $indovina = $parola[1]; $_SESSION['gcid'] = $parola[0]; $indovinata = CalcolaIndovinata ($indovina, $scelte, $alfabeto); $_SESSION['gctempo'] = time(); } // set the cookie (or the get variable) via PHP sessions $_SESSION['gchangman'] = ($indovina.'/'.$scelte.'/'.$tentativi); if ($tentativi>6) $tentativi=6; // load the first part of the template $pagina = file($template); $totrighe = count($pagina); $i = 0; while (rtrim($pagina[$i])!="") { print $pagina[$i]; $i++; } // print the word hiding the unfound letters print ('

Miss '.$tentativi.'/6

'); echo ("\n

\n"); $caratteri = preg_split('//', $indovinata, -1, PREG_SPLIT_NO_EMPTY); foreach ($caratteri as $lettalf) { $lettalf = strtr ($lettalf, $alfabeto); if ($lettalf==' ') { print (' '); } else { print (' '.$lettalf.''); } echo ("\n"); print (' '); echo ("\n"); } print ('

'); // last part if ($indovina!=$indovinata) { if ($tentativi>=6) { // ahi! hanged! print ('

'.HANGED); if ($showsol) print(' '.WORDWAS.' '.$indovina); $bestnow = CercaRecord ($user, $pword, $dhost, $dbase, $dtable, $_SESSION['gcid']); if ($bestnow[1]==6) print ('
'.NONE.'

'); else { if ($bestnow[0]=='') $bestnow[0]=ANON; print ('
'.$bestnow[0].' '.GUESSEDIT.' '.$bestnow[2].' '.SECONDS.' '.$bestnow[1].' '.CHANCES.'.

'); } } else { // shows the full alphabet from which the letters can be chosen $scelt = preg_split('//', $scelte, -1, PREG_SPLIT_NO_EMPTY); echo ("\n

\n"); foreach ($alfabeto as $lettalf) { $contrl = false; foreach ($scelt as $lett) { if (!strcasecmp ($lettalf, $lett)) { $contrl = true; } } if ($contrl) { print (' '.$lettalf.''); } else { print (' '.$lettalf.''); } if ($lettalf=='m') echo ("\n
"); echo ("\n"); } echo ("

\n"); } } else { // the word has been guessed! echo ("\n

\n"); print (CONGRAT); $tempo = time() - $_SESSION['gctempo']; $oldbest = ControllaRecord ($user, $pword, $dhost, $dbase, $dtable, $_SESSION['gcid'], $tempo, $tentativi); if ($oldbest[1]=='') $oldbest[1]=ANON2; if ($oldbest[0]) { // and there's a new record print ('
'.GUESST); if ($oldbest[1]!='*nuovo**') print (' '.BEAT.' '.$oldbest[1]); require_once ('DB.php'); $dsn = "mysql://$user:$pword@$dhost/$dbase"; $db = DB::connect($dsn, true); if (DB::isError($db)) die ($db->getMessage()); $res = $db->query('update '.$dtable. ' set errors = '.$tentativi.', time = '.$tempo. ' where id = '.$_SESSION['gcid']); if (DB::isError($res)) die ($res->getMessage()); $db->disconnect(); // here is the form to insert own name ?>

'.SOMEBUT.' '.$oldbest[1].' '.GUESSEDIT.' '.$oldbest[3].' '.SECONDS.' '.$oldbest[2].' '.CHANCES.'.

'); } // show the final part of the template print ('

'.NWGAME.'

'); $i++; while ($i<$totrighe) { print $pagina[$i]; $i++; } ?>