Esempio n. 1
0
function getStatName($stat)
{
    if (!is_array($stat)) {
        $stat = getStat($stat);
    }
    return array("name" => $stat['name'], "fullName" => $stat['fullName']);
}
Esempio n. 2
0
 function getCpuUsage($_statPath = '/proc/stat')
 {
     $msge = "<div id='getCpuUsage'><small class='r'>getCpuUsage():<br />couldn't access STAT path</small></div><script type='text/javascript'>function killElement(){ document.getElementById('getCpuUsage').style.display='none'; } setTimeout('killElement()', 5000);</script>";
     $time1 = getStat($_statPath) or false;
     sleep(1);
     $time2 = getStat($_statPath) or false;
     $delta = array();
     if ($time1 != false && $time2 != false) {
         foreach ($time1 as $k => $v) {
             $delta[$k] = $time2[$k] - $v;
         }
         $deltaTotal = array_sum($delta);
         $percentages = array();
         foreach ($delta as $k => $v) {
             $percentages[$k] = @round($v / $deltaTotal * 100, 2);
         }
         return $percentages;
     } else {
         return $msge;
         //return false;
     }
 }
Esempio n. 3
0
         $tripod->saveChanges($oldGraph, new \Tripod\ExtendedGraph());
     });
     $app->post('/', function ($storeName, $podName) use($app, $tripodOptions) {
         $tripodOptions['statsConfig'] = getStat($app, $tripodOptions);
         $tripod = new \Tripod\Mongo\Driver($podName, $storeName, $tripodOptions);
         $rawGraphData = $app->request()->getBody();
         $graph = new \Tripod\Mongo\MongoGraph();
         $graph->add_rdf($rawGraphData);
         $tripod->saveChanges(new \Tripod\ExtendedGraph(), $graph);
     });
 });
 $app->group('/change', function () use($app, $tripodOptions) {
     $app->post('/', function ($storeName, $podName) use($app, $tripodOptions) {
         \Tripod\Mongo\Config::setConfig(json_decode(file_get_contents('./config/tripod-config-' . $storeName . '.json'), true));
         $app->response()->setStatus(500);
         $tripodOptions['statsConfig'] = getStat($app, $tripodOptions);
         $tripod = new \Tripod\Mongo\Driver($podName, $storeName, $tripodOptions);
         $rawChangeData = $app->request()->post('data');
         if ($rawChangeData) {
             $changeData = json_decode($rawChangeData, true);
             $from = new \Tripod\Mongo\MongoGraph();
             $to = new \Tripod\Mongo\MongoGraph();
             if (isset($changeData['originalCBDs'])) {
                 foreach ($changeData['originalCBDs'] as $change) {
                     if (is_array($change) && isset($change[_ID_KEY])) {
                         $from->add_tripod_array($change);
                     }
                 }
             }
             if (isset($changeData['newCBDs'])) {
                 foreach ($changeData['newCBDs'] as $change) {
Esempio n. 4
0
<?php

include_once "include/check_login.php";
if ($user_ok == false) {
    header('location: restricted.php?refPage=mydecks');
}
/******************************************************************************************************************/
require_once 'stats.php';
$pid = getUserID($_SESSION['username']);
$lv = getStat('lv', $pid);
$pDecks = getUserDecks($pid);
$pDecksSrtAscArr = sortDeckArrDN($pDecks);
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>My Decks </title>
	<!--<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">-->
	<link rel="stylesheet" type="text/css" href="css/readable.bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/newStyle.css">
	<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
	<!--<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">-->
	<!--[if lt IE 9]>
	<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script type="text/javascript">
		<!-- 
		//Browser Support Code
		function _(el){
Esempio n. 5
0
	<link rel="stylesheet" type="text/css" href="css/newStyle.css">
	<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
</head>
<body>
	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-8 table-responsive">
			<h1>PVP</h1>
			<?php
			$i =2;
			foreach($pvpDis as $rank){?>
				<div class="row">
					<div class="col-xs-12">
						<?= getPvpRank(getPvpUI($pvpDis[$i])); ?>
						<span id="user<?= $i;?>"><?= getUserDetail(getPvpUI($pvpDis[$i]),'username'); ?>, </span>
						Lvl <?= getStat('lv',getPvpUI($pvpDis[$i])); ?>
						<a href="#3" id="battle<?= $i;?>" name="">Battle</a>
					</div>
				</div><?
				$i--;
			} ?>
			
			
		</div>
		<div class="col-md-2"></div>
	</div>
	<script>
		var battle2 = document.getElementById("battle2");
		var battle1 = document.getElementById("battle1");
		var battle0 = document.getElementById("battle0");
		var user2 = document.getElementById("user2").innerHTML;
Esempio n. 6
0
 function getCpuUsage($_statPath = '/proc/stat')
 {
     $time1 = getStat($_statPath);
     if (!$time1) {
         return -1;
     }
     sleep(1);
     $time2 = getStat($_statPath);
     $delta = array();
     foreach ($time1 as $k => $v) {
         $delta[$k] = $time2[$k] - $v;
     }
     $deltaTotal = array_sum($delta);
     $percentages = array();
     foreach ($delta as $k => $v) {
         $percentages[$k] = @round($v / $deltaTotal * 100, 2);
     }
     return $percentages;
 }
Esempio n. 7
0
<?php

require_once "auth.php";
require_once "smarty.php";
require_once "backend/functions.php";
$stat = getStat();
$smarty->assign("users_all", $stat['Users']['All']);
$smarty->assign("users_admin", $stat['Users']['Admin']);
$smarty->assign("FiberSplice_NetworkNodesCount", $stat['FiberSplice']['NetworkNodesCount']);
$smarty->assign("NetworkNodeCountInFiberSplice", $stat['FiberSplice']['NetworkNodeCountInFiberSplice']);
$smarty->assign("FiberSplice_FiberSpliceCount", $stat['FiberSplice']['FiberSpliceCount']);
$smarty->assign("CableLinePointCount", $stat['CableLinePoint']['Count']);
$smarty->assign("NetworkNodesCount", $stat['NetworkNode']['Count']);
$smarty->assign("NetworkBoxesCount", $stat['NetworkBox']['Count']);
$smarty->display("index.tpl");
Esempio n. 8
0
<?php

session_start();
$name = $_SESSION['username'];
include $_SERVER['DOCUMENT_ROOT'] . '/include/db_browsergame.inc.php';
require $_SERVER['DOCUMENT_ROOT'] . '/browsergame/inc/logincheck.inc.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/browsergame/functions/stats.function.php';
$setHP = getStat('sethp', $userID);
if ($setHP == 0) {
    setStat('curhp', $userID, 10);
    setStat('maxhp', $userID, 10);
    setStat('sethp', $userID, 1);
}
$attack = getStat('atk', $userID);
$magic = getStat('mag', $userID);
$defence = getStat('def', $userID);
$gold = getStat('gc', $userID);
$currentHP = getStat('curhp', $userID);
$maximumHP = getStat('maxhp', $userID);
require "main.html.php";
Esempio n. 9
0
    $msg = '	Total citations ignored for IA: ';
    $sql = "SELECT COUNT(DISTINCT nid) AS total FROM citebank_internet_archive_records WHERE archive_status = -1";
    getStat($dbi, $msg, $sql);
    $totalCitationsExternallyHosted = $totalCitations - $totalIACitations;
    echo '<br>';
    $msg = '	Citations in CB (externally hosted content files): ';
    echo $msg . $totalCitationsExternallyHosted;
    // ****************************************
    // ****************************************
    // ****************************************
} else {
    // just public stats
    // total citations
    $msg = '	Total citations: ';
    $sql = "SELECT COUNT(*) AS total FROM node AS n JOIN biblio AS b ON (n.nid = b.nid) WHERE n.type = 'biblio'";
    getStat($dbi, $msg, $sql);
}
statsEchoLine();
/*
 *
 */
function getStat($dbi, $msg, $sql)
{
    $rows = $dbi->fetch($sql);
    $count = 0;
    if (count($rows) > 0) {
        $count = $rows[0]['total'];
    }
    echo '<br>';
    echo $msg . $count;
    return $count;
Esempio n. 10
0
 private function seoPages($task)
 {
     $mainframe =& JFactory::getApplication();
     $this->addSubmenu('pages_view');
     require_once "classes/MetatagsContainerFactory.php";
     $itemType = JRequest::getVar('type', null, '', 'string');
     if (!$itemType) {
         $itemType = key(MetatagsContainerFactory::getFeatures());
     }
     $metatagsContainer = MetatagsContainerFactory::getContainerById($itemType);
     if (!is_object($metatagsContainer)) {
         //TODO: throw error here.
     }
     switch ($task) {
         case "pages_save_text":
             $metatagsContainer->setMetadata($id = JRequest::getVar('id', '', '', 'int'), array("title" => JRequest::getVar('title', '', '', 'string'), "metatitle" => JRequest::getVar('metatitle', '', '', 'string'), "metakeywords" => JRequest::getVar('metakeywords', '', '', 'string'), "metadescription" => JRequest::getVar('metadescription', '', '', 'string')));
             echo "<script>window.parent.document.adminForm.submit();</script>";
             break;
         case "pages_edit_text":
             $id = JRequest::getVar('id', '', '', 'int');
             $data = $metatagsContainer->getMetadata($id);
             $data["id"] = $id;
             $view =& $this->getView('Pages');
             $view->assignRef('itemType', $itemType);
             $view->assignRef('data', $data);
             $view->display('edit');
             break;
         default:
             $limit = JRequest::getVar('limit', $mainframe->getCfg('list_limit'));
             $limitstart = JRequest::getVar('limitstart', 0);
             $db =& JFactory::getDBO();
             $pages = $metatagsContainer->getPages($limitstart, $limit);
             $db->setQuery('SELECT FOUND_ROWS();');
             //no reloading the query! Just asking for total without limit
             jimport('joomla.html.pagination');
             $pageNav = new JPagination($db->loadResult(), $limitstart, $limit);
             require_once "algorithm/KeywordsCounter.php";
             for ($i = 0; $i < count($pages); $i++) {
                 $stat_arr = array();
                 for ($j = 0; $j < count($pages[$i]->metakey); $j++) {
                     $stat_arr[] = getStat($pages[$i]->metakey[$j], $pages[$i]->content);
                 }
                 $pages[$i]->stat = $stat_arr;
             }
             $view =& $this->getView('Pages');
             $view->assignRef('itemType', $itemType);
             $view->assignRef('rows', $pages);
             $view->assignRef('page', $page);
             $view->assignRef('itemsOnPage', $itemsOnPage);
             $view->assignRef('filter', $metatagsContainer->getFilter());
             $view->assignRef('availableTypes', MetatagsContainerFactory::getFeatures());
             $view->assignRef('pageNav', $pageNav);
             $view->display();
     }
 }
Esempio n. 11
0
<?php

session_start();
include '../stats.php';
echo getStat('gc', getUserID(preg_replace('#[^a-z0-9]#i', '', $_SESSION['username'])));
Esempio n. 12
0
			<div class="row"><?php
				$someDecks = getSomeDecks($t);
				$j=0;
				foreach($someDecks as $row => $deck){
					if(!$deck['is_sentences']){
						$deckOwners = countDeckOwners($deck['display_name']);
						if($j % 2 == 0){ ?><div class="clearfix visible-sm"></div><? }
						if($j % 3 == 0){ ?><div class="clearfix visible-md visible-lg"></div><? }?>
						<div class="col-sm-6 col-md-4">
							<div class="thumbnail">
							  <img src="../img/<?= $deck['picture'];?>" class="img-responsive" alt="<?= $deck['display_name'];?> Vocabulary" class="img-responsive">
							  <div class="caption">
								<h4><a href="http://www.JPVocab.com/Japanese-Vocabulary/deck.php?t=<?= $t;?>&d=<?= $deck['display_url']; ?>"><?= $deck['display_name'];?></a></h4>
								<p>
									 
									<a href="#2" data-toggle="popover" title="Deck Owners" data-content="<? if($user_ok ==false){ echo "Oh hey! You need to <strong>Login</strong> to do that.";}else{ foreach($deckOwners as $row => $user){ echo "<a href='http://www.jpvocab.com/player.php?player=".$user['username']."&report=summary'>". $user['username'] ."</a> <i class='text-muted small '>Lvl <strong>".getStat('level',$user['id'])."</strong></i><br />"; } }?>" data-trigger="focus" data-html="true"><small><strong><?= sizeOf($deckOwners); ?></strong> Users</a> Own This Deck</small>
								</p>
								<p><?= $deck['description'];?></p>
								<p>
									<a href="http://www.JPVocab.com/Japanese-Vocabulary/deck.php?t=<?= $t;?>&d=<?= $deck['display_url']; ?>" class="btn btn-default btn-block" role="button">Interested?</a>
								</p>
							  </div>
							</div>
						</div><?php
						$j++;
					}
				}?>
				<!--<small><a href="http://www.JPVocab.com/flashcard-rewards.php" alt="Japanese flashcard reward system">What the heck are <span class="label label-warning">Gold</span> and <span class="label label-default">Diamonds</span>?</a></small>-->
			</div>
		</div>
	</div>
         if ($count > 0) {
             # already has one of the item
             $query = sprintf("UPDATE user_items SET quantity = quantity + 1 WHERE user_id = '%s' AND item_id = '%s'", mysql_real_escape_string($userID), mysql_real_escape_string($itemID));
         } else {
             # has none - new row
             $query = sprintf("INSERT INTO user_items(quantity,user_id,item_id) VALUES (1,'%s','%s')", mysql_real_escape_string($userID), mysql_real_escape_string($itemID));
         }
         mysql_query($query);
         # retrieve the item name, so that we can display it
         $query = sprintf("SELECT name FROM items WHERE id = %s", mysql_real_escape_string($itemID));
         $result = mysql_query($query);
         list($itemName) = mysql_fetch_row($result);
         $smarty->assign('item', $itemName);
         $monster_exp = getMonsterStat('exp', $monsterID);
         $smarty->assign('exp', $monster_exp);
         $exp_rem = getStat('exp_rem', $userID);
         $exp_rem -= $monster_exp;
         $level_up = 0;
         if ($exp_rem <= 0) {
             // level up!
             $exp_rem = 100;
             $level_up = 1;
         }
         $smarty->assign('level_up', $level_up);
         setStat('exp_rem', $userID, $exp_rem);
     } else {
         // monster won
         $smarty->assign('lost', 1);
     }
     $smarty->assign('combat', $combat);
 } else {
Esempio n. 14
0
function setMoneyBalances($sElement, $sMethod, $userId)
{
    $userFunds = getStat($sMethod, $userId);
    $elementP = getPrice($sElement, $sMethod);
    $balance = $userFunds - $elementP;
    if ($balance >= 0) {
        setStat($sMethod, $userId, $balance);
        return 'success';
    }
}
<?php

require_once 'smarty.php';
session_start();
require_once 'config.php';
// our database settings
require_once 'stats.php';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname);
// retrieve user ID
$query = sprintf("SELECT id FROM users WHERE UPPER(username) = UPPER('%s')", mysql_real_escape_string($_SESSION['username']));
$result = mysql_query($query);
list($userID) = mysql_fetch_row($result);
if ($_POST) {
    $amount = $_POST['amount'];
    $gold = getStat('gc', $userID);
    $needed = getStat('maxhp', $userID) - getStat('curhp', $userID);
    if ($amount > $needed || $amount == '') {
        $amount = $needed;
    }
    if ($amount > $gold) {
        $amount = $gold;
    }
    setStat('gc', $userID, getStat('gc', $userID) - $amount);
    setStat('curhp', $userID, getStat('curhp', $userID) + $amount);
    $smarty->assign('healed', $amount);
}
$smarty->assign('curhp', getStat('curhp', $userID));
$smarty->assign('maxhp', getStat('maxhp', $userID));
$smarty->assign('gold', getStat('gc', $userID));
$smarty->display('healer.tpl');
Esempio n. 16
0
$def = getStat('def', $pid);
$gc = getStat('gc', $pid);
$confidence = getStat('conf', $pid);
$maxconf = getStat('maxconf', $pid);
$lv = getStat('lv', $pid);
$cvDN = getDeckInfo(getSkill('cvset', $pid), 'display_name');
$currentHP = getStat('curhp', $pid);
$maximumHP = getStat('maxhp', $pid);
$setHP = getStat('sethp', $pid);
$ttldks = getStat('ttldks', $pid);
$ttlpvstyl = getStat('ttlpvstyl', $pid);
$sumcfc = getStat('sumcfc', $pid);
$sumckanjiRE = getStat('sumckanjiRE', $pid);
$sumckanjiE = getStat('sumckanjiE', $pid);
$sumckanjiH = getStat('sumckanjiH', $pid);
$sumcaudioR = getStat('sumcaudioR', $pid);
$vocabulary = round(getScore('vocabulary', $pid), 2);
$listening = round(getScore('listening', $pid), 2);
$kanji = round(getScore('kanji', $pid), 2);
$ttldks = countUserDecks($pid);
$pDecks = getUserDecks($pid);
$pDecksSrtAscArr = sortDeckArrDN($pDecks);
//careful with this. vertNav.php uses $uDecksSrtAscArr
include "pdc.php";
try {
    $stmt = $db->query("SELECT  uo.*,\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\tSELECT  COUNT(*)\n\t\t\t\t\t\t\tFROM    user_stats ui\n\t\t\t\t\t\t\tWHERE   (ui.value) >= (uo.value)\n\t\t\t\t\t\t\tAND ui.stat_id=14\n\t\t\t\t\t\t\t) AS rank\n\t\t\t\t\t\tFROM    user_stats uo\n\t\t\t\t\t\tWHERE user_id={$pid}\n\t\t\t\t\t\tAND stat_id=14");
    $urank = $stmt->fetchALL(PDO::FETCH_ASSOC);
} catch (PDOException $ex) {
    echo "Couldn't get rank <br />";
}
$ranktfca = $urank[0]['value'] != 0 ? $urank[0]['rank'] : 'N/A';
Esempio n. 17
0
<?php

session_start();
$name = $_SESSION['username'];
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/dump.include.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/include/db_browsergame.inc.php';
require $_SERVER['DOCUMENT_ROOT'] . '/browsergame/inc/logincheck.inc.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/browsergame/functions/stats.function.php';
$phand = getStat('phand', $userID);
$shand = getStat('shand', $userID);
if ($_POST) {
    setStat('phand', $userID, $shand);
    setStat('shand', $userID, $phand);
    $temp = $shand;
    $shand = $phand;
    $phand = $temp;
}
try {
    $sql = "SELECT name FROM items WHERE id = :phand";
    $s = $pdo->prepare($sql);
    $s->bindValue(':phand', $phand);
    $s->execute();
} catch (PDOException $e) {
    $error = 'Error fetching primary hand.' . $e->getMessage();
    include $_SERVER['DOCUMENT_ROOT'] . '/include/error.html.php';
    exit;
}
if ($s) {
    list($phand_name) = $s->fetch(PDO::FETCH_ASSOC);
    $phand = $phand_name;
}
Esempio n. 18
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';
?>



Esempio n. 19
0
                }
            } else {
                $first = 0;
            }
        }
        return $cores;
    }
    /* compares two information snapshots and returns the cpu percentage */
    function getCpuUsage($stat1, $stat2)
    {
        if (count($stat1) !== count($stat2)) {
            return;
        }
        for ($i = 0; $i < count($stat1); $i++) {
            $diff_idle[$i] = $stat2[$i]['idle'] - $stat1[$i]['idle'];
            $diff_total[$i] = $stat2[$i]['total'] - $stat1[$i]['total'];
            $DU = round(1000 * ($diff_total[$i] - $diff_idle[$i]) / $diff_total[$i] / 10, 2);
            $diff_usage[$i] = $DU > 100 ? 100 : $DU;
        }
        return $diff_usage;
    }
    $stat1 = getStat();
    sleep(1);
    $stat2 = getStat();
    $cores = getCpuUsage($stat1, $stat2);
    $nocpushow = "0";
} elseif ($os == "nocpu") {
    $nocpushow = "1";
} else {
    $nocpushow = "1";
}
Esempio n. 20
0
        </center>
    </div>
</div>
</header>
<?php 
if (isset($_SESSION['username'])) {
    ?>
	<div class="container">
	<div class="row no-marg-top-23" style="font-size:0.8em">
		<div class="col-xs-12 col-sm-6 text-left">
				<a href="http://www.JPVocab.com/users.php" alt="Online JPVocab Users" title="View Online Users"><u><?php 
    echo $uOnQ;
    ?>
</u></a>
		</div>
		<div class="col-xs-12  col-sm-6 pull-right text-right">
			<span>You have <b><span id="headerGC" class="text-success"><?php 
    echo getStat('gold', $_SESSION['userid']);
    ?>
</span></b> <span class="label label-warning">Gold Coins</span>
			<!--and <span class="label label-default"><?php 
    echo getStat('diamonds', $_SESSION['userid']);
    ?>
 Diamonds</span> <a href="http://www.JPVocab.com/diamond.php" title="Get Diamonds"><i>Get Diamonds</i></span></a>-->
		</div>
	</div>
	</div>
	<?php 
}
?>
<script src="../js/update-status.js" type="text/javascript"></script>
Esempio n. 21
0
<?php

header('Content-Type: text/html; charset=utf-8');
include_once "include/check_login.php";
if ($user_ok == false) {
    header('location: restricted.php?refPage=train');
}
require_once 'config.php';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname);
require_once 'stats.php';
$userID = getUserID(preg_replace('#[^a-z0-9]#i', '', $_SESSION['username']));
$player = array(name => preg_replace('#[^a-z0-9]#i', '', $_SESSION['username']), attack => getStat('atk', $userID), defence => getStat('def', $userID), magic => getStat('mag', $userID), curhp => getStat('curhp', $userID), maxhp => getStat('maxhp', $userID), level => getStat('lv', $userID), xp => getStat('conf', $userID), maxxp => getStat('maxconf', $userID), gold => getStat('gc', $userID));
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="robots" content="NOODP">
	<meta name="description" content="Japanese Flashcards. Many decks. Many styles. - jpvocab.com">
	<title>Train - jpvocab.com</title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
	<link rel="stylesheet" type="text/css" href="css/readable.bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/newStyle.css">
	<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
	
	<!--[if lt IE 9]>
Esempio n. 22
0
     } else {
         $attacker =& $player;
         $defender =& $monster;
     }
     $damage = 0;
     if ($attacker['attack'] > $defender['defence']) {
         $damage = $attacker['attack'] - $defender['defence'];
     }
     $defender['curhp'] -= $damage;
     $combat[$turns] = array(attacker => $attacker['name'], defender => $defender['name'], damage => $damage);
     $turns++;
 }
 setStat('curhp', $userID, $player['curhp']);
 if ($player['curhp'] > 0) {
     // player won
     setStat('gc', $userID, getStat('gc', $userID) + getMonsterStat('gc', $monsterID));
     $won = 1;
     $gold = getMonsterStat('gc', $monsterID);
     $rand = rand(0, 100);
     try {
         $sql = "SELECT item_id FROM monster_items WHERE monster_id = :monsterid AND rarity >= :rand ORDER BY RAND() LIMIT 1";
         $s = $pdo->prepare($sql);
         $s->bindValue(':monsterid', $monsterID);
         $s->bindValue(':rand', $rand);
         $s->execute();
     } catch (PDOException $e) {
         $error = 'Error fetching item from monster.' . $e->getMessage();
         include $_SERVER['DOCUMENT_ROOT'] . '/include/error.html.php';
         exit;
     }
     list($itemID) = $s->fetch();
Esempio n. 23
0
        }
    }
}
try {
    $result = $pdo->query('SELECT DISTINCT(id), name, price FROM items WHERE type = \'Armor\' ORDER BY RAND() LIMIT 10');
} catch (PDOException $e) {
    $error = 'Error fetching item name and price from the database!';
    include $_SERVER['DOCUMENT_ROOT'] . '/include/error.html.php';
    exit;
}
foreach ($result as $row) {
    $armor[] = array('id' => $row['id'], 'name' => $row['name'], 'price' => $row['price']);
}
$stats = array('atorso', 'ahead', 'alegs', 'aright', 'aleft');
foreach ($stats as $key) {
    $id = getStat($key, $userID);
    try {
        $sql = 'SELECT name FROM items WHERE id = :id';
        $s = $pdo->prepare($sql);
        $s->bindValue(':id', $id);
        $s->execute();
    } catch (PDOException $e) {
        $error = 'Error getting name from items,';
        include $_SERVER['DOCUMENT_ROOT'] . '/include/error.html.php';
        exit;
    }
    if ($s) {
        list($name) = $s->fetch(PDO::FETCH_ASSOC);
        $key = $name;
    }
}
 if ($_POST['sell']) {
     $weaponID = getStat($_POST['sell'], $userID);
     $query = sprintf("SELECT price FROM items WHERE id = %s", mysql_real_escape_string($weaponID));
     $result = mysql_query($query);
     list($price) = mysql_fetch_row($result);
     $gold = getStat('gc', $userID);
     setStat('gc', $userID, $gold + $price);
     setStat($_POST['sell'], $userID, '');
     $phand = getStat('phand', $userID);
     $shand = getStat('shand', $userID);
 } else {
     $weaponID = $_POST['weapon-id'];
     $query = sprintf("SELECT price FROM items WHERE id = %s", mysql_real_escape_string($weaponID));
     $result = mysql_query($query);
     list($cost) = mysql_fetch_row($result);
     $gold = getStat('gc', $userID);
     if ($gold >= $cost) {
         // subtract gold, equip weapon, go from there.
         if (!$phand) {
             setStat('phand', $userID, $weaponID);
             setStat('gc', $userID, $gold - $cost);
             $phand = $weaponID;
             $smarty->assign('message', 'You equipped the weapon in your primary hand.');
         } else {
             if (!$shand) {
                 setStat('shand', $userID, $weaponID);
                 setStat('gc', $userID, $gold - $cost);
                 $shand = $weaponID;
                 $smarty->assign('message', 'You equipped the weapon in your secondary hand.');
             } else {
                 $smarty->assign('error', 'You already have two weapons! You must sell one before equipping another one.');
                    addStat(getStat($p, $id, true, true), $winrateC, $ch);
                }
                foreach ($items as $i) {
                    addStat(getStat($p, $i, false), $poprateI, $i);
                    addStat(getStat($p, $i, true), $winrateI, $i);
                    addStat(getStat($p, $i, false, false, $arr["matchDuration"]), $dpsI, $i);
                }
                foreach ($boots as $i) {
                    addStat(getStat($p, $i, false, false, false, 2), $poprateB, $i);
                    addStat(getStat($p, $i, true, false, false, 2), $winrateB, $i);
                    addStat(getStat($p, $i, false, false, $arr["matchDuration"], 2), $dpsB, $i);
                }
                foreach ($mr as $i) {
                    addStat(getStat($p, $i, false, false, false, 3), $poprateMR, $i);
                    addStat(getStat($p, $i, true, false, false, 3), $winrateMR, $i);
                    addStat(getStat($p, $i, false, false, $arr["matchDuration"], 3), $dpsMR, $i);
                }
                getIC($p, $champs, $popArray);
                getIC($p, $champs, $winArray, true);
                getIC($p, $champs, $popArrayB, false, 2);
                getIC($p, $champs, $winArrayB, true, 2);
            }
        }
    }
    closedir($handle);
}
/////////////////////////////////////////////////////////
foreach ($winrateC[1] as $item => $stat) {
    if ($winrateC[2][$item] == 0) {
        $winrateC[0][$item] = 0;
    } else {
Esempio n. 26
0
//INCREMENT JPDRILLS_USAGE
$category = preg_replace('#[^a-z0-9]#i', '', $_GET['type']);
$difficulty_pre = preg_replace('#[^a-z0-9]#i', '', $_GET['diff']);
$difficulty = difficulty_str_to_int($difficulty_pre);
$drill_type = preg_replace('#[^a-z0-9]#i', '', $_GET['choiceQ']) != 'none' ? 'wordbox' : 'Fill-in-the-blank';
increment_usage($category, $difficulty, $drill_type);
if (isset($_POST) || isset($_GET)) {
    if ($_POST['action'] == 'Answer') {
        if (isset($_SESSION['username'])) {
            require_once '../stats.php';
            $cvset = getSkill('cvset', $userID);
            $query = sprintf("SELECT id FROM users WHERE UPPER(username) = UPPER('%s')", mysql_real_escape_string($_SESSION['username']));
            $result = mysql_query($query);
            list($userID) = mysql_fetch_row($result);
            //assigns fetched username's 'id' to $userID to use in list fn.
            $player = array(name => $_SESSION['username'], confidence => getStat('conf', $userID));
        }
        //Compare wrong and right answers
        $phraseID = $_POST['phraseID'];
        $blankQ = getBlanks($phraseID, 'fib_word');
        $answers = getFIBAdjWordAnswers($phraseID, 'fib_word_answers');
        for ($j = 1; $j < $blankQ + 1; $j++) {
            $userInput[] = $_POST['word' . $j];
        }
        $wrongAnswers = array_diff_assoc($userInput, $answers);
        $rightAnswers = array_intersect_assoc($answers, $userInput);
        $nWrong = sizeof($wrongAnswers);
        $gcReward = ($blankQ - $nWrong) * 2;
        //Set stats based on results
        //set conf, particle, cvset
        //conf
Esempio n. 27
0
     for ($i = 0; $i < sizeof($skills); $i++) {
         setScore($skills[$i], $userID, getScore($skills[$i], $userID) + $scoreIncr);
         $changeLog[] = "<li>" . getStatInfo($skills[$i], 'display_name') . ":<b> +{$scoreIncr}</b> Confidence points</li>";
     }
     //$changeLog[] = "<li>Overall Player Confidence:<b>+$confCorrGain</b> Confidence points</span></li>";
     //$changeLog[] = "<li>Quiz Mode:<b> +$skillCorrGain</b> Confidence points</span></li>";
     //$changeLog[] = "<li>Streak Bonus: <b>+$streakBonus</b> Confidence points</span></li>";
     //------------------INCREMENT GENERAL SKILLS
     $result = "<span style='color:green;'>CORRECT!</span>";
 } elseif ($wordIDGuess != $answerID) {
     $correct = false;
     setStat('conf', $userID, getStat('conf', $userID) - $confWrongPen);
     //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
Esempio n. 28
0
session_start();
header('Content-Type: text/html; charset=utf-8');
include_once "../include/check_login.php";
if ($user_ok == false) {
    header("location: ../restricted.php");
}
include_once '../stats.php';
include "../pdc.php";
$skill = $_POST['el'];
$price = $_POST['val'];
$uid = getUserID(preg_replace('#[^a-z0-9]#i', '', $_POST['user']));
$sessUid = getUserID(preg_replace('#[^a-z0-9]#i', '', $_SESSION['username']));
$gold = getStat('gold', $uid);
//double check post is same as session username
if ($uid != $sessUid) {
    echo "error";
    die;
} else {
    if ($gold < $price) {
        echo "error";
        die;
    } else {
        setStat($skill, $uid, getStat($skill, $uid) + 1);
        setStat('gold', $uid, getStat('gold', $uid) - $price);
        echo "success";
    }
}
//double check enough gold
//increase skill
//decrease gold
Esempio n. 29
0
echo getDeckFullUrl(getSkill('cvset', $user['id']));
?>
">
											<?php 
echo getDeckInfo(getSkill('cvset', $user['id']), 'display_name');
?>

										</a></small>
									</td>
								</tr>
								<tr><td colspan="2"><small><b><?php 
echo getStat('ttldks', $user['id']);
?>
</b> Decks owned</small></td></tr>
								<tr><td colspan="2"><small><b><?php 
echo getStat('ttlpvstyl', $user['id']);
?>
</b> Quiz Modes owned</small></td></tr>
							</table>
							
						</div>
						<hr><?
					}?>
				</div>
			</div>
		</div>
	</div>
		<!-- ********************Include Footer ******************************--><?php 
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/footer-new.php';
?>
<?php

require_once 'smarty.php';
require_once 'login-check.php';
require_once 'stats.php';
$smarty->assign('attack', getStat('atk', $userID));
$smarty->assign('magic', getStat('mag', $userID));
$smarty->assign('defence', getStat('def', $userID));
$smarty->assign('gold', getStat('gc', $userID));
$setHP = getStat('sethp', $userID);
if ($setHP == 0) {
    // haven't set up the user's HP values yet - let's set those!
    setStat('curhp', $userID, 10);
    setStat('maxhp', $userID, 10);
    setStat('sethp', $userID, 1);
}
$smarty->assign('currentHP', getStat('curhp', $userID));
$smarty->assign('maximumHP', getStat('maxhp', $userID));
$smarty->assign('name', $_SESSION['username']);
$smarty->display('index.tpl');