function getSentence($length)
{
    $result = getWord();
    for ($i = 0; $i < $length - 1; $i++) {
        $result .= ' ' . getWord();
    }
    return $result;
}
function getSentence($parts)
{
    $randLength = mt_rand(2, 6);
    //first wrd with uppercase
    getWordUpp($parts);
    echo " ";
    //calling  functions 4 to 8 times
    for ($i = 0; $i < $randLength; $i++) {
        getWord($parts);
        echo " ";
    }
    getWord($parts);
    echo ". ";
}
function getWord($n)
{
    if ($n < 10) {
        return $GLOBALS['digits'][$n - 1];
    } elseif ($n > 10 and $n < 20) {
        return $GLOBALS['teens'][$n - 11];
    } elseif ($n % 10 == 0 and $n % 100 != 0 and $n < 100) {
        return $GLOBALS['tens'][$n / 10 - 1];
    } elseif ($n % 100 == 0 and $n % 1000 != 0) {
        return $GLOBALS['digits'][$n / 100 - 1] . "hundred";
    } elseif ($n % 1000 == 0) {
        $i = $n / 1000;
        return $GLOBALS['digits'][$i - 1] . "thousand";
    } elseif ($n > 20 and $n < 100) {
        return $GLOBALS['tens'][($n - $n % 10) / 10 - 1] . $GLOBALS['digits'][$n % 10 - 1];
    } elseif ($n > 100 and $n < 1000) {
        $remainder = $n % 100;
        $hundreds = ($n - $remainder) / 100;
        return $GLOBALS['digits'][$hundreds - 1] . "hundredand" . getWord($remainder);
    }
}
Exemple #4
0
function getWord($index, $word)
{
    global $arResult;
    global $counter;
    //stop recursion
    if (!count($word) > $index) {
        return;
    }
    for ($i = $index; $i < count($word); $i++) {
        $tempWord = $word;
        if ($i != $index) {
            //changing positions of letters
            $tempWord[$index] = $word[$i];
            $tempWord[$i] = $word[$index];
            $stringTempWord = implode($tempWord);
            //filling result array
            $arResult[] = $stringTempWord;
            $counter++;
        }
        //calling recursion
        getWord($index + 1, $tempWord);
    }
    return;
}
Exemple #5
0
        $_SESSION['streak'] = 0;
        $result = "<span style='color:#E15119'>WRONG..</span>";
    }
    $changeLog[] = "</ul></div>";
    //*******************************************************************************
    //********CHECK IF PLAYER LEVELED UP & PREPARE DISPLAY VARIABLES*****************
    //*******************************************************************************
    $lvUp = setLevelUp($userID, 'quiz');
    //change lv's if needed
    //Prepare Summary of Guess Results (correct/incorrect) for User Display
    $previousQ = "<span style='color:green;'>" . getWord($_POST['questionID'], $questionFromBank) . "</span>";
    if (getSkill('vStyle', $userID) == 'kanjiH') {
        $previousA = "<span style='color:green;'>" . getReading($answerID, $answerFromBank) . "</span>";
    } else {
        $previousA = "<span style='color:green;'>" . getWord($answerID, $answerFromBank) . "</span>";
    }
    $origQ = getWord($_POST['questionID'], $questionFromBank);
    $lv = getStat('lv', $userID);
    $currentConf = getStat('conf', $userID);
    $maxconf = getStat('maxconf', $userID);
    $currConfPerc = $currentConf / $maxconf * 100;
    $vsLv = getSkill($cvset . '_' . $vstyle . '_lv', $userID);
    $vsProg = getSkill($cvset . '_' . $vstyle . '_prog', $userID);
    $vsProgMax = getSkill($cvset . '_' . $vstyle . '_prog_max', $userID);
}
include '../display_mc.php';
?>



Exemple #6
0
							<td><i class="fa fa-ellipsis-v"></i></td>
						</tr>
						<tr>
							<td class="text-danger text-center"><?php 
echo $d['size'];
?>
</i></td>
							<td class="text-center"><abbr title="<?php 
echo $top[$prNum]['reading'];
?>
"><?php 
echo $top[$prNum]['kanji'];
?>
</abbr></td>
							<td><?php 
echo getWord(getOppositeWordID($top[$prNum]['id'], 'jtest'), 'etest');
?>
</abbr></td>
							<td class="text-danger text-center"><?php 
echo $d['levels'];
?>
</i></td>
						</tr>
					</table>
				</div><!-- end RIGHT COLUMN-->
			</div>
		</div>
	</div>
</section>
<hr>
<!--<section>
Exemple #7
0
    return $suffix[$suffix_key];
}
$cartArray = $_SESSION['minishop2']['cart'];
$n = count($cartArray) - $limit;
$products = '';
$arr = array_slice($cartArray, 0, $limit);
foreach ($arr as $val) {
    if ($product = $modx->getObject('msProduct', $val['id'])) {
        $products .= '<img src="' . $product->get('thumb') . '" height="25" class="b-minicart-preview" alt="" title="" />';
    }
}
if ($products == '') {
    $products = 'Ваша корзина пуста';
} else {
    $products .= '<a href="/cart" class="btn btn-default">Оформить заказ</a>';
}
$res = '';
switch ($action) {
    case 'updateCart':
        if ($n > 0) {
            $word = getWord($n);
            $res = $products . ' и еще ' . $n . ' ' . $word;
        } else {
            $res = $products;
        }
        break;
}
$res = $modx->toJSON(array('success' => 'ok', 'data' => $res));
if (!empty($res)) {
    die($res);
}
Exemple #8
0
<?php

for ($beers = 99; $beers >= 0; $beers--) {
    $oneLess = $beers - 1;
    $bottles = getWord($beers);
    $bottlesOneLess = getWord($oneLess);
    if ($beers > 0) {
        echo "{$beers} {$bottles} of beer on the wall, {$beers} {$bottles} of beer.\n" . "Take one down and pass it around, {$oneLess} {$bottlesOneLess} of beer on the wall.\n\n";
    } else {
        echo "No more bottles of beer on the wall, no more bottles of beer,\n" . "Go to the store and buy some more, 99 bottles of beer on the wall.\n\n";
    }
}
/**
 * Gibt die Einzahl- oder Mehrzahl-Form 
 * für das Wort "bottle" zurück.
 * 
 * @param  int $count
 * @return string
 */
function getWord(int $count) : string
{
    return $count === 1 ? 'bottle' : 'bottles';
}
Exemple #9
0
<input type="hidden" id="ratingtid" value="{$id}" />
<div id="rating_selector">
\t<span class="rating star" title="{$tracker_lang['vote_1']}" data-value="1">
\t<span class="rating star" title="{$tracker_lang['vote_2']}" data-value="2">
\t<span class="rating star" title="{$tracker_lang['vote_3']}" data-value="3">
\t<span class="rating star" title="{$tracker_lang['vote_4']}" data-value="4">
\t<span class="rating star" title="{$tracker_lang['vote_5']}" data-value="5">
\t</span></span></span></span></span>
</div>
SELECTOR;
        $is_voted = mysql_fetch_array(sql_query('SELECT rating FROM ratings WHERE torrent = ' . $id . ' AND user = '******'id']));
        if (mysql_error()) {
            sqlerr();
        }
        if ($is_voted) {
            $stars .= ratingpic($row['rating']) . "(" . $row["rating"] . " " . $tracker_lang['from'] . " 5 " . $tracker_lang['with'] . " " . $row["numratings"] . " " . getWord($row["numratings"], array($tracker_lang['votes_1'], $tracker_lang['votes_2'], $tracker_lang['votes_3'])) . ")" . ' Ваша оценка <b>' . $is_voted['rating'] . '</b> - <b>' . $tracker_lang['vote_' . $is_voted['rating']] . '</b>';
        } else {
            $stars .= $rating_selector;
        }
        tr($tracker_lang['rating'], $stars, 1);
    }
    tr($tracker_lang['added'], $row["added"]);
    tr($tracker_lang['views'], $row["views"]);
    tr($tracker_lang['hits'], $row["hits"]);
    tr($tracker_lang['snatched'], $row["times_completed"] . " " . $tracker_lang['times']);
    $keepget = "";
    $uprow = isset($row["username"]) ? "<a href=userdetails.php?id={$row["owner"]}>" . htmlspecialchars_uni($row["username"]) . "</a>" : "<i>{$tracker_lang['details_anonymous']}</i>";
    /*
    if ($owned)
            $uprow .= " $spacer<$editlink><b>[{$tracker_lang['edit']}]</b></a>";
    */
Exemple #10
0
        //overall conf stat
        setSkill($progressVoc, $userID, getSkill($progressVoc, $userID) - $skillWrongPen);
        //cvset prog skill
        setStat('gold', $userID, getStat('gold', $userID) - $gcPen);
        //gold
        incrUserDeckStat('stats_incorrect', $cvset, $vstyle, $userID);
        for ($i = 0; $i < sizeof($skills); $i++) {
            setStat($skills[$i], $userID, getScore($skills[$i], $userID) - $scoreDecr);
            $changeLog[] = "<li>" . getStatInfo($skills[$i], 'display_name') . ": <span class='text-danger'>-{$scoreDecr} Confidence points</span></li>";
        }
        $_SESSION['streak'] = 0;
    }
    //Update Statistics	//insertFlashcardResults($user_id,$deck_id,$word_id,$word_lv,$vstyle_id,$correct,$time_taken);
    //******************************************************
    //****CHECK IF PLAYER LEVELED UP & PREPARE DISPLAY VARIABLES***
    //********************************************
    $lvUp = setLevelUp($userID, 'quiz');
    //change lv's if needed
    //***Used to give display correct answer if user guessed wrong
    $original_kanji = getWord($_POST['questionID'], $questionFromBank);
    $reading_tmp = getReading($_POST['questionID'], $questionFromBank);
    $original_reading = $original_kanji == $reading_tmp ? '-' : getReading($_POST['questionID'], $questionFromBank);
    $original_translation = getWord($answerID, 'etest');
}
include '../mc_get.php';
include '../include/kanjiRE.php';
?>



Exemple #11
0
<html>
  <head>
    <title>STEP HW7</title>
  </head>
  <body>
    <?php 
function getWord($pos)
{
    $urls = array("http://step15-krispop.appspot.com/", "http://tsumu-2015.appspot.com/", "http://regal-sun-100211.appspot.com/", "http://step-1003.appspot.com/", "http://jukunyannyan.appspot.com/", "http://natsuko-step2015.appspot.com/", "http://kei-step2015.appspot.com/", "http://step2015-minoue1204.appspot.com/", "http://step-mami.appspot.com/");
    $n = rand(0, count($urls) - 1);
    $word = file_get_contents($urls[$n] . "getword?pos=" . $pos);
    return $word;
}
$word1 = getWord("");
$word2 = getWord("");
$word3 = getWord("");
$word4 = getWord("");
echo $word1 . "! he said " . $word2 . " as he jumped into his convertible " . $word3 . " and drove off with his " . $word4 . " wife.";
?>
  </body>
<html>
Exemple #12
0
<?php

if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
    die;
}
$wordId = $_GET['id'];
require_once 'config.php';
require 'design_head.php';
$word = getWord($wordId);
print_r($word);
require 'design_foot.php';
<?php

// See if we should clear cookies
if (isset($_GET['clear'])) {
    clearCookies();
}
// Set a new cookie
$value = getWord() . "-" . getWord() . "-" . getWord();
$cookieName = "CS337-Test-Cookie-" . time();
$expiration = time() + 3600;
setcookie($cookieName, $value, $expiration);
function clearCookies()
{
    foreach ($_COOKIE as $cookieName => $v) {
        // Set expiration to some time in the past
        $expiration = time() - 3600;
        setcookie($cookieName, null, $expiration);
    }
}
// Get a random word from a wordlist
function getWord()
{
    $numWords = 31860;
    $randWordRow = rand(1, $numWords);
    $wordlist = fopen('wordlist.txt', 'r');
    $i = 0;
    while ($i < $randWordRow) {
        $word = fgets($wordlist);
        $i++;
    }
    chop($word);
Exemple #14
0
<?php

include "module_index_head.php";
include "bddconnect.php";
$words = getWord($_GET["id"]);
?>


<html>

<head>
    <title> cloud </title>
    <link rel="stylesheet" href="style.css"/>
    <meta charset="utf-8">
</head>

<body>


<div class="wrapper">

    <ul class="cloud" style="list-style-type : none;">
        <?php 
foreach ($words as $word) {
    ?>

            <a style="text-decoration:none;" href="index.php?word=<?php 
    echo utf8_encode($word["mot"]);
    ?>
">
                <li class="link<?php 
Exemple #15
0
<?php

$Page = empty($_GET['Page']) ? '' : trim(strip_tags(substr($_GET['Page'], 0, 64)));
// XSS prevention.
$Action = empty($_GET['Action']) ? '' : trim(strip_tags(substr($_GET['Action'], 0, 64)));
// XSS prevention.
require_once realpath('Protected/Included_Raw.inc');
// 2Do: create the non-AJAX version:
/*
One more thing. If you want, you don't even have to change the URL for
doing the ajax version. jQuery sets the "X-Requested-With" request
header to "XmlHttpRequest" for ajax requests, so you could just check
for that on the server and return JSON if you find it and your regular
HTML if you don't.
*/
if (!empty($Page) && file_exists(realpath($HomeDir . 'Protected/Modules/' . $Page . '.inc'))) {
    require realpath($HomeDir . 'Protected/Modules/' . $Page . '.inc');
} elseif (!empty($Page)) {
    echo getWord($Page);
} else {
    echo getWord('About');
}
echo "\n";
Exemple #16
0
$db = new SQLite3($dbFile);
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($sock !== false) {
    if (socket_bind($sock, $address, $port) !== false) {
        if (socket_listen($sock) !== false) {
            $working = true;
            echo "Hello. Now you can join " . $address . ':' . $port . "\n";
            system("start http://" . $address . ':' . $port);
            do {
                $socket = socket_accept($sock);
                if ($socket !== false) {
                    $buffer = socket_read($socket, 4096, PHP_BINARY_READ);
                    if ($buffer !== false) {
                        if (strpos($buffer, "GET") !== FALSE || strpos($buffer, "POST") !== FALSE) {
                            if (strpos($buffer, " / ")) {
                                $word = getWord($db);
                                if ($word === false) {
                                    $HTML = file_get_contents('http/finish.htm');
                                } else {
                                    $HTML = file_get_contents('http/index.htm');
                                    $HTML = str_replace('{WORD}', $word['word'], $HTML);
                                    $HTML = str_replace('{WORDID}', $word['id'], $HTML);
                                    $HTML = str_replace('{TRANSLATE}', $word['translate'], $HTML);
                                }
                                $HEADER = file_get_contents('http/200.txt');
                                $HEADER = str_replace('{length}', strlen($HTML), $HEADER);
                                $ANSWER = $HEADER . $HTML;
                            } else {
                                if (strpos($buffer, '/check')) {
                                    $ANSWER = file_get_contents('http/redirectIndex.txt');
                                    if (strpos($buffer, 'isOk=yes')) {
Exemple #17
0
    $answerChoices[$rand]['id'] = $answerID;
    $answerChoices[$rand][$element] = $answer;
    //print_r($answerChoices);
    //Finalized Variables Used in kanjiRE.php
    $question = $vstyle == 'audioR' || $vstyle == 'audioK' ? getWordInfo('audio_filename', $questionID, $questionFromBank) : getWord($questionID, $questionFromBank);
    if (isSentencesDeck(getVocStat('cvset', $userID)) == '1') {
        $sentences = getSentences($questionID);
    } else {
        $sentences = False;
    }
} elseif (getSkill('vStyle', $userID) == 'engK' || getSkill('vStyle', $userID) == 'engKR') {
    //***************************************************************************************************
    //*************************************English<-->Kanji+Hiragana; Hiragana***************************
    //***************************************************************************************************
    //$choiceQ = 5;
    $questionFromBank = 'etest';
    $answerFromBank = 'jtest';
    //get word
    $questionID = getQuizWordID($userID, getSkill('vStyle', $userID));
    //echo "newQuesID is: $questionID <br />";
    $question = getWord($questionID, $questionFromBank);
    $answerID = getAnswerIDVocab($questionID, $questionFromBank);
    $answer = getWord($answerID, $answerFromBank);
    //get random words in HIRAGANA
    $answerChoices = getRandomWords($choiceQ, $answerFromBank, $answerID, $userID, 'word');
    //need to get hiragana, not kanji
    //hide answer within choices
    $rand = rand(0, $choiceQ - 1);
    $answerChoices[$rand] = $answer;
    list($choice1, $choice2, $choice3, $choice4, $choice5) = $answerChoices;
}
Exemple #18
0
function noRepeat()
{
    include 'config.php';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
    mysql_select_db($dbname);
    $cvset = getSkill('cvset', $userID);
    $query = sprintf("SELECT id FROM jtest WHERE {$cvset} !=0 AND {$cvset} <='%s' AND word != reading ORDER BY RAND() LIMIT 1", mysql_real_escape_string(getSkill($cvset . "_lv", $userID)));
    $result = mysql_query($query) or die(mysql_error());
    list($question) = mysql_fetch_row($result);
    //echo $question;
    $word = getWord($question, 'jtest');
    $r = getReading($question, 'jtest');
    //echo "$word::$r </br>";
    if (getWord($question, 'jtest') == getReading($question, 'jtest')) {
        echo "Found duplicate word({$word}) and reading({$r}), finding another </br>";
        noRepeat();
    } else {
        return $question;
    }
}
Exemple #19
0
function get_elapsed_time_plural($time_start, $decimals = 0)
{
    $divider['years'] = 60 * 60 * 24 * 365;
    $divider['months'] = 60 * 60 * 24 * 365 / 12;
    $divider['weeks'] = 60 * 60 * 24 * 7;
    $divider['days'] = 60 * 60 * 24;
    $divider['hours'] = 60 * 60;
    $divider['minutes'] = 60;
    $langs['years'] = array("год", "года", "лет");
    $langs['months'] = array("месяц", "месяца", "месяцев");
    $langs['weeks'] = array("неделю", "недели", "недель");
    $langs['days'] = array("день", "дня", "дней");
    $langs['hours'] = array("час", "часа", "часов");
    $langs['minutes'] = array("минуту", "минуты", "минут");
    foreach ($divider as $unit => $div) {
        ${'elapsed_time_' . $unit} = floor((TIMENOW - $time_start) / $div);
        if (${'elapsed_time_' . $unit} >= 1) {
            break;
        }
    }
    $elapsed_time = ${'elapsed_time_' . $unit} . ' ' . getWord(${'elapsed_time_' . $unit}, $langs[$unit]);
    return $elapsed_time;
}
Exemple #20
0
        exit;
    }
}
require_once "dictionary.inc.php";
if (isset($_POST['data']) && $_POST['data']) {
    $data = $_POST['data'];
} else {
    if (isset($_SESSION['data']) && $_SESSION['data']) {
        $data = $_SESSION['data'];
        $_SESSION['data'] = null;
    }
}
if (!$data) {
    // Pick the word/letter
    if ($_SESSION['type'] == "Words") {
        $data = getWord();
    } else {
        if ($_SESSION['type'] == "Letters") {
            $data = getLetter();
        } else {
            if ($_SESSION['type'] == "Sentences") {
                $data = getSentence(rand(1, 6));
            } else {
                if ($_SESSION['type'] == "Koch Method") {
                    $data = getKochSentence($_SESSION['koch_size'], rand(1, 6));
                }
            }
        }
    }
}
?>
Exemple #21
0
    ?>

			<tr>
				<td class="text-center"><small><?php 
    echo $word['q'];
    ?>
</small></td>
				<td class="text-center" >
					<abbr title="<?php 
    echo $word['reading'];
    ?>
"><?php 
    echo $word['kanji'];
    ?>
</abbr>
				</td>
				<td class="text-left">
					<?php 
    echo getWord(getOppositeWordID($word['id'], 'jtest'), 'etest');
    ?>

				</td>
				<td class="text-center"><?php 
    echo $word['lv'];
    ?>
</td>
			</tr><?php 
}
?>

	</table>
Exemple #22
0
    array_push($arr, strlen($str));
    $start = $arr[$pos - 1];
    foreach ($arr as $k => $v) {
        if ($k == $pos) {
            $str1 = substr_amit($str, $start, $v);
        }
    }
    return $str1;
}
function substr_amit($str, $start, $end)
{
    $arr = array();
    $str1 = "";
    for ($i = 0; $i < strlen($str); $i++) {
        $arr[$i] = $str[$i];
    }
    foreach ($arr as $k => $v) {
        if ($k == $start) {
            $str1 .= $v;
        }
        if ($k > $start && $k < $end) {
            $str1 .= $v;
        }
        if ($k == $end) {
            $str1 .= $v;
        }
    }
    return $str1;
}
echo getWord("I AM AMIT KUMAR MONDAL", 2);