function main() { global $numEpochs; global $numPatterns; global $patNum; global $RMSerror; // initiate the weights initWeights(); // load in the data initData(); // train the network for ($j = 0; $j <= $numEpochs; $j++) { for ($i = 0; $i < $numPatterns; $i++) { //select a pattern at random //srand(); $patNum = rand(0, $numPatterns - 1); //calculate the current network output //and error for this pattern calcNet(); //change network weights WeightChangesHO(); WeightChangesIH(); } //display the overall network error //after each epoch calcOverallError(); if (gmp_mod($j, 50) == 0) { print "epoch = " . $j . " RMS Error = " . $RMSerror . "</br>"; } } //training has finished //display the results displayResults(); }
$counter += 1; echo "\r <tr align = 'center' id = '{$counter}' onmouseover = 'changeRowColor(this,true);' \r onmouseout = 'changeRowColor(this,false);' onClick='pageRedirect({$counter});'>\r <td>{$rows['id']}</td>\r <td>{$rows['date']}</td>\r <td>{$rows['type']}</td>\r <td>{$rows['first_name']}</td>\r <td>  {$rows['last_name']}  </td>\r <td>{$rows['email']}</td>\r </tr>"; } } /* * Function to display headers of the table with information pertaining to a customer's orders */ function myOrders($status, $custID) { echo "\r <script type='text/javascript'>\r function changeRowColor (Row,State)\r {\r if(State)\r {\r Row.style.backgroundColor = '#E0E0E0';\r Row.style.color = 'Black';\r }\r else\r {\r Row.style.backgroundColor = '#f6f6f6';\r Row.style.color = 'Black';\r }\r }\r\r \r function pageRedirect(indexOfRow)\r {\r var order = document.getElementById('ordersTable').rows[indexOfRow].cells[0].innerHTML;\r document.location.href = 'myOrders.php?orderID='+order;\r // alert(indexOfRow+\"order = \"+order);\r }\r \r\r </script>\r </head>\r <body>\r <h3>Click to View Order</h3>\r <div id='profileBox'></div>\r <form action='{$PHP_SELF}' method='POST'>\r <table align='center' id='ordersTable' class='profile_sect'>\r <tr align = 'center'>\r <th>     Order ID     </th>\r <th>     Order Date     </th>\r <th>     Order Type     </th>\r <th>     Employee First Name     </th>\r <th>     Employee Last Name     </th>\r <th>     Employee e-Mail ID     </th>\r\r </tr>"; global $db;
function showResults($array, $teamFor, $teamAgainst) { $complete = FALSE; foreach ($array as $value) { if ($value['Team One'] == $teamFor) { if ($value['Team Two'] == $teamAgainst) { displayResults($value); $complete = TRUE; } } } if ($complete == FALSE) { echo "Bad Selection"; } }
function findSavings() { $row = $_POST['row']; $implode = implode(',', $row); $explode = explode(',', $implode); $itemNumber = $explode[0]; $retail = $explode[5]; $selectPromotionsForItemStatement = "Select * From PromotionItem WHERE ItemNumber = '" . $itemNumber . "'"; $promotionItemResult = mysql_query($selectPromotionsForItemStatement); //Test whether the queries were successful if (!$promotionItemResult) { $promotionItemMessage = "The retrieval of promotion items was unsuccessful: "; } $numberPromotionItemRows = mysql_num_rows($promotionItemResult); // Check if results turned out empty $promotionItemMessage = ""; if ($numberPromotionItemRows == 0) { $promotionItemMessage = "No items found in database"; } $bestPromo = $retail; $bestPrice = "none"; $adEvent = "none"; while ($row = mysql_fetch_assoc($promotionItemResult)) { $promoCode = $row['PromoCode']; $salePrice = $row['SalePrice']; if ($salePrice < $bestPrice) { $selectAdEventsForPromotionStatement = "Select * From AdEventPromotion WHERE PromoCode = '" . $promoCode . "'"; $adEventPromotionResult = mysql_query($selectAdEventsForPromotionStatement); //Test whether the queries were successful if (!$adEventPromotionResult) { $adEventPromotionMessage = "The retrieval of promotion items was unsuccessful: "; } $numberAdEventPromotionRows = mysql_num_rows($adEventPromotionResult); // Check if results turned out empty $adEventPromotionMessage = ""; if ($numberAdEventPromotionRows == 0) { $adEventPromotionMessage = "No items found in database"; } else { $result = mysql_fetch_assoc($adEventPromotionResult); $eventCode = $result['EventCode']; $bestPrice = $salePrice; $bestPromo = $promoCode; $adEvent = $eventCode; } } } displayResults($itemNumber, $retail, $bestPrice, $bestPromo, $adEvent); }
$leagueID = leagueHandler($_POST, $userID); debug("League is {$leagueID}"); $season = getSeason(); ?> To join a league, choose the league you're looking to join, the password provided by its administrator, and the name of your team. You can only join a league once. If a league's registration deadline has passed, it does not appear on the list.<p/> <?php debug($_POST["action"]); if ($_POST["action"] == "leagueEnroll") { $pass = getSingleton("fch_leagues", "pw", " where id = " . $_POST['leagueID'] . " and season = \"" . getSeason() . "\""); debug("Criteria -- displName=" . $_POST["teamDisplayName"] . " pw=" . $_POST['password'] . " pass="******"teamDisplayName"]) > 0) { echo displayResults(addGMToLeague($_POST["leagueID"], $userID, $_POST["teamDisplayName"])); } else { echo displayResults(getReturnCode(0, "Sorry, your password was incorrect or you didn't enter a team name.")); } } ?> <div class="contact-form"> <form name="leagueEnroll" method="post" class="form-validate form-horizontal" > <input name = "action" value = "leagueEnroll" type = "hidden"> <fieldset> <legend>What League Would You Like to Join?</legend> <div class="control-group"> <div class="control-label"> <label id="jform_contact_name-lbl" for="jform_contact_name" class="hasTooltip required" title="<strong>Name</strong><br />Your name."> League</label> </div>
} } if ($_POST["action"] == "removeGM") { if (!okToTransact($_POST["transactionID"])) { echo displayResults(getReturnCode(0, "This transaction has already been completed. Please do not use the refresh button.")); } else { $gmToDelete = intval($_POST["gmToDelete"]); debug("Removing {$gmToDelete} from league {$leagueID}"); $r = executeGenericSQL("UPDATE fch_league_membership SET status = \"removed\" WHERE userID = {$gmToDelete} and {$leagueID} = leagueID and season = \"{$season}\""); if ($r != -1) { $r = executeGenericSQL("UPDATE fch_rosters SET releaseDate = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL +3 HOUR) where userID = {$gmToDelete} and leagueID = {$leagueID} and releaseDate is NULL and season = \"{$season}\" "); if ($r != -1) { echo displayResults(getReturnCode(1, "Successfully removed this GM.")); } } else { echo displayResults(getReturnCode(0, "There has been an error releasing this GM's players.")); } } setTransactionComplete($_POST["transactionID"]); } ?> <h3>More Admin Tools Coming Soon.</h3> <h4>Registration Deadline</h4> <?php echo getSingleton("fch_leagues", "registrationDeadline", " WHERE id = {$leagueID} and season = \"{$season}\""); ?>
echo "<div class=\"row-fluid\">"; echo "<div class=\"span3\">"; //echo "<h2 class=\"text-center\">Cluster 1<br /></h2>"; echo "<p class=\"text-center\"><b>Keywords:" . "</b><br />{$titlesCluster1}<br />"; displayResults($cluster1); echo "</div>"; echo "<div class=\"span3\">"; //echo "<h2 class=\"text-center\">Cluster 2<br /></h2>"; echo "<p class=\"text-center\"><b>Keywords: " . "</b><br />{$titlesCluster2}<br />"; displayResults($cluster2); echo "</div>"; echo "<div class=\"span3\">"; //echo "<h2 class=\"text-center\">Cluster 3<br /></h2>"; echo "<p class=\"text-center\"><b>Keywords: " . "</b><br />{$titlesCluster3}<br />"; displayResults($cluster3); echo "</div>"; echo "<div class=\"span3\">"; //echo "<h2 class=\"text-center\">Cluster 4<br /></h2>"; echo "<p class=\"text-center\"><b>Keywords: " . "</b><br />{$titlesCluster4}<br />"; displayResults($cluster4); echo "</div>"; echo "</div>"; } //************************************************************************** } //check memory usage //(not available on csserver) //echo "<br /> " . memory_get_peak_usage() . "<br /> "; } //Include footer file require 'includes/searchFooter.php';
case "date": $date = "'" . $_POST['sCriteria'] . "'"; $db->runQuery("select CL.lead_id , CL.customer_id ,\n first_name, last_name ,email, CL.employee_id , date, L.type\n from customer_leads CL, customers C, Leads L where\n CL.date={$date} and C.id = CL.customer_id and L.id = CL.lead_id;"); if ($db->result->num_rows > 0) { displayResults($db); $customerFound = 1; } else { echo "<script>location.href='viewEditLead.php?error=1'</script>"; } break; } echo "</table></form></body></html>"; get_footer(); } if (isset($_GET['status']) && !isset($_GET['error'])) { $status = $_GET['status']; echo "<html>\n <head>\n <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />\n <script type='text/javascript'>\n function changeRowColor (Row,State)\n {\n if(State)\n {\n Row.style.backgroundColor = '#E0E0E0';\n Row.style.color = 'Black';\n }\n else\n {\n Row.style.backgroundColor = '#f6f6f6';\n Row.style.color = 'Black';\n }\n }\n\n function pageRedirect(indexOfRow)\n {\n var lead = document.getElementById('leadsTable').rows[indexOfRow].cells[0].innerHTML;\n document.location.href = 'leadUpdate.php?leadID='+lead;\n\n }\n </script>\n </head>\n <body>\n <h3>Click to View / Update Lead</h3>\n <div id='profileBox'></div>\n <form action='{$PHP_SELF}' method='POST'>\n <table align='center' id='leadsTable' class='profile_sect'>\n <tr align = 'center'>\n <th>     Lead ID     </th>\n <th>     Customer ID     </th>\n <th>     First Name     </th>\n <th>     Last Name     </th>\n <th>     e-Mail ID     </th>\n <th>     Sales Person's ID     </th>\n <th>     Date     </th>\n <th>     Lead Type     </th>\n </tr>\n "; switch ($status) { case 'Open': $db->runQuery("select CL.lead_id , CL.customer_id ,\n C.first_name, C.last_name ,C.email, CL.employee_id , date, L.type\n from customer_leads CL, customers C, Leads L where\n L.status = 'open' and L.id = CL.lead_id and C.id = CL.customer_id;"); break; case 'Closed': $db->runQuery("select CL.lead_id , CL.customer_id ,\n C.first_name, C.last_name ,C.email, CL.employee_id , date, L.type\n from customer_leads CL, customers C, Leads L where\n L.status = 'closed' and L.id = CL.lead_id and C.id = CL.customer_id;"); break; } displayResults($db); } if (isset($_GET['error'])) { echo "<h3>ERROR: Not found!</h3>"; echo '<br/><br/><form><input type="submit" value="Try Again" onClick="history.go(-1);return true;"> </form>'; }
$output .= displayScore($phpscore, $this->sl_get_path(), "php"); $output .= " </div>"; $output .= " <div style=\"width: 24%; float: left;\">"; $output .= displayScore($slscore, $this->sl_get_path(), "sl"); $output .= " </div>"; $output .= " <div style=\"width: 24%; float: left;\">"; $output .= displayScore($cmsscore, $this->sl_get_path(), "cms"); $output .= " </div>"; $output .= " <div style=\"width: 24%; float: left;\">"; $output .= displayScore($overallscore, $this->sl_get_path(), "overall"); $output .= " </div>"; $output .= " </div>"; $output .= "</div>"; $output .= "<div style=\"clear: both;\"></div>"; $output .= "<div style=\"width: 918px;\">"; $output .= displayResults($warnings, $pass); $output .= "</div>"; } /** * Display the results in a nice looking form * * @param mixed $bad * @param mixed $good */ function displayResults($bad, $good){ $n = "\n"; $message = ""; //$message .= "<script type=\"text/javascript\" charset=\"utf-8\">var myTabs = new mootabs('myTabs', {height: 440, width:895});</script>".$n; $message .= "<div id=\"myTabs\">".$n; $message .= " <ul class=\"mootabs_title\" style=\"background: url('../images/alert-icon.png');\">".$n;
Due to the 12-hour rule, players are not available to manage here for the 12 hours immediately following the start time of a game in which their school is participating. For more information see <a href="./index.php/about/game-rules">Game Rules</a> under "Roster Moves." <?php $document = JFactory::getDocument(); #$document->addScript('fch-lib.js'); require_once "fch-lib.js"; require_once "fch-lib.php"; $userID = getUserID(); $leagueID = leagueHandler($_POST, $userID); debug("League is {$leagueID}"); $season = getSeason(); if ($_POST['action'] == "doAcquire") { echo displayResults(acquirePlayer($userID, $leagueID, $_POST['playerID'], $_POST['destination'], $_POST['position'], $_POST["transactionID"])); } $limit_f_a = getPositionLimit("F", "a", $leagueID); $limit_f_b = getPositionLimit("F", "b", $leagueID); $limit_d_a = getPositionLimit("D", "a", $leagueID); $limit_d_b = getPositionLimit("D", "b", $leagueID); $limit_g_a = getPositionLimit("G", "a", $leagueID); $limit_g_b = getPositionLimit("G", "b", $leagueID); $roster_f_a = selectCount("fch_rosters", " Where season = \"{$season}\" and leagueID = {$leagueID} and userID = {$userID} and releaseDate is null and position = \"F\" and statusCode = \"act\""); $roster_f_b = selectCount("fch_rosters", " Where season = \"{$season}\" and leagueID = {$leagueID} and userID = {$userID} and releaseDate is null and position = \"F\" and statusCode = \"ben\""); $roster_d_a = selectCount("fch_rosters", " Where season = \"{$season}\" and leagueID = {$leagueID} and userID = {$userID} and releaseDate is null and position = \"D\" and statusCode = \"act\""); $roster_d_b = selectCount("fch_rosters", " Where season = \"{$season}\" and leagueID = {$leagueID} and userID = {$userID} and releaseDate is null and position = \"D\" and statusCode = \"ben\""); $roster_g_a = selectCount("fch_rosters", " Where season = \"{$season}\" and leagueID = {$leagueID} and userID = {$userID} and releaseDate is null and position = \"G\" and statusCode = \"act\""); $roster_g_b = selectCount("fch_rosters", " Where season = \"{$season}\" and leagueID = {$leagueID} and userID = {$userID} and releaseDate is null and position = \"G\" and statusCode = \"ben\""); ?> <p/> <h3>Your Roster Slots (used/allowed)</h3> <style>
<?php session_start(); ?> <?php if (isset($_GET['lat']) && isset($_GET['long']) && isset($_GET['radius'])) { displayResults($_GET['lat'], $_GET['long'], $_GET['radius']); } function displayResults($lat, $long, $radius) { $_SESSION["myLat"] = $lat; $_SESSION["myLong"] = $long; } header('refresh: 0; url=main.php');
<?php require_once "fch-lib.js"; require_once "fch-lib.php"; if ($_POST['action'] == "doCreateLeague") { debug("creating league"); echo displayResults(createLeague($_POST['leagueDisplayName'], $_POST['password'], $_POST['teamDisplayName'], $_POST["limit_f_a"], $_POST["limit_f_b"], $_POST["limit_d_a"], $_POST["limit_d_b"], $_POST["limit_g_a"], $_POST["limit_g_b"], $_POST["registrationDate"] . " " . $_POST["registrationTime"], $_POST["draftDate"] . " " . $_POST["draftTime"], $_POST["invitees"])); } ?> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script> /* function validateDates() { var regDate = new Date(document.forms["createLeague"].elements["registrationDate"].value + " " + document.forms["createLeague"].elements["registrationTime"].value); var draftDate = new Date(document.forms["createLeague"].elements["draftDate"].value + " " + document.forms["createLeague"].elements["draftTime"].value); if ((draftDate - regDate) < 86400000) { alert("Your draft must be 24 hours or more after your registration date."); return false; } return true; } */ function intValue(field) { return parseInt(document.forms["createLeague"].elements[field].value);
while ($row = mysql_fetch_assoc($restults_academic_calendar)) { $upcomingArray[$upcomingCount]['date_from'] = $row['date_from']; $upcomingArray[$upcomingCount]['time_from'] = NULL; $upcomingArray[$upcomingCount]['location'] = NULL; $upcomingArray[$upcomingCount]['date_to'] = $row['date_to']; $upcomingArray[$upcomingCount]['title'] = $row['description']; $upcomingArray[$upcomingCount]['url'] = NULL; $upcomingArray[$upcomingCount]['semester'] = $row['semester']; $upcomingArray[$upcomingCount]['type'] = NULL; $upcomingArray[$upcomingCount]['ts_speaker'] = NULL; $upcomingArray[$upcomingCount]['ts_affiliation'] = NULL; $upcomingCount++; } rsort($upcomingArray); // display results displayResults($upcomingArray); } } if (isset($_POST['freq']) && $_POST['freq'] == 'tech') { $currentDate = currentDate(); $sql = "SELECT * FROM events WHERE (type='tech session' && status='approved' AND date_from > '2014-01-01') ORDER BY date_from ASC"; $results = mysql_query($sql) or die("Unable to execute:" . mysql_error()); ?> <style> #tech td { padding:8px; } </style><br /> <p> <strong>All the sessions will be held in GS 100 at 4:00 PM</strong>
displayError("Could not update IP tracking."); exit; } setcookie("voted", "255", strtotime($config["expiration"])); } else { if (!mysql_query("INSERT INTO `{$dbTblT}` VALUES('{$userIP}','" . $_POST["voteFor"] . "','1',NOW());")) { displayError("Could not update IP tracking."); exit; } setcookie("voted", $_POST["voteFor"], strtotime($config["expiration"])); } if (!mysql_query("UPDATE `{$dbTblR}` SET `votes` = votes + 1 WHERE `id` = '" . $_POST["voteFor"] . "' LIMIT 1;")) { displayError("Could not update vote result."); exit; } displayResults(0); exit; } /////////////////// function getIP($ip) { return long2ip($ip); } function putIP($ip) { return ip2long(gethostbyname($ip)); } function openProxy() { // conceptualized by frostjedi.com; heavily modified global $_GET, $_SERVER, $PHP_SELF;
function nextDraftOrder($leagueID) { $picksSoFar = intval(selectCount("fch_draft", " WHERE leagueID = {$leagueID}")); $totalPlayers = intval(selectCount("fch_league_membership", " WHERE leagueID = {$leagueID} and status = \"active\"")); $max = getLastPickNumber($leagueID) + 1; // because we want the NEXT player $season = getSeason(); debug($picksSoFar . " " . $totalPlayers . " " . $max); if (!($totalPlayers > 0)) { displayResults(getReturnCode(0, "Error: No players in this league.")); } $quotient = intval(($max - 1) / $totalPlayers); debug("quotient {$quotient}"); $mod = ($max - 1) % $totalPlayers + 1; debug("mod {$mod}"); if ($quotient % 2 == 0) { $r = intval($mod); debug("{$r} = r"); } else { $r = intval($totalPlayers - $mod + 1); debug("{$r} = r"); } return $r; }
// Expect b_ to be baseline, s_ to be status as updated by user if (substr($key, 0, 2) == "s_") { $playerID = substr($key, 2); debug("Player is " . $playerID . " trigger is " . $_POST["s_" . $playerID]); if ($_POST["s_" . $playerID] == "dirty") { debug("RELEASING " . $playerID); $r = releasePlayer($userID, $leagueID, $playerID, $_POST["transactionID"]); $x++; } } } if ($x == 0) { $r["status"] = 0; $r["msg"] = "You did not select any players to drop."; } echo displayResults($r); } ?> <script> jQuery(function($) { jQuery(document).ready(function (){ jQuery('#l2').on('click','li',function(){ var t=jQuery(this); jQuery('#l1').append(t); //alert(jQuery("#s_" + this.id).val()); jQuery("#s_" + this.id).val("ok");
global $db; $db->runQuery("select * from discounts where id={$offerID};"); $rows = $db->result->fetch_assoc(); echo "<h1>Offer Details</h1>\n <div id=\"profileBox\">\n <table class=\"profile_sect\">\n <tr>\n <td class = 'field'>Offer ID</td>\n <td class = field'>{$rows['id']}</td>\n </tr>\n <tr>\n <td class = 'field'>Description</td>\n <td class = field'>{$rows['description']}</td>\n </tr>\n <tr>\n <tr>\n <td class = 'field'>Value [% Discount]</td>\n <td class = field'>{$rows['value']}</td>\n </tr>\n <tr>\n <td class = 'field'>Criteria [No. of Orders]</td>\n <td class = field'>{$rows['criteria']}</td>\n </tr>\n <tr>\n <td class = 'field'>Lead Type</td>\n <td class = field'>{$rows['lead_type']}</td>\n </tr>\n <td class = 'field'>Start Date</td>\n <td class = field'>{$rows['start_date']}</td>\n </tr>\n <tr>\n <td class = 'field'>End Date</td>\n <td class = field'>{$rows['end_date']}</td>\n </tr>\n</table></div>\n\n "; } if (isset($_GET['offerID']) && !isset($_POST['submit'])) { global $db; fetchOffer($_GET['offerID']); $offerID = $_GET['offerID']; displayResults($db, $offerID, 'ongoing'); } if (isset($_GET['upcomingOfferID']) && !isset($_POST['submit'])) { global $db; fetchOffer($_GET['upcomingOfferID']); $offerID = $_GET['upcomingOfferID']; displayResults($db, $offerID, 'upcoming'); } if (isset($_GET['pastOfferID']) && !isset($_POST['submit'])) { fetchOffer($_GET['pastOfferID']); echo "<h2> The offer has expired. It cannot be offered to any customer </h2>"; } function displayResults($db, $offerID, $message) { $today = date("Y-m-d"); $db->runQuery("select DISTINCT customer_id from customer_leads;"); $counter = 0; if ($db->result->num_rows > 0) { while ($customerRows = $db->result->fetch_assoc()) { $activeCustomersArray[$counter++] = $customerRows['customer_id']; } for ($i = 0; $i < $counter; $i++) {
function getCreatedBy($id) { displayResults(search_events("", "", "", "", "", "", $id)); }
/** * Stop tests and display the results * * @return void outputs directly */ function stopTestsAndDisplay() { global $keepOpen; if (count($_SESSION['testResults'])) { displayResults($_SESSION['testResults'], $keepOpen); } resetTests(); }
if (strlen($_POST["action"]) > 0) { $_GET = null; } ////////// GET if ($_GET["action"] == "rescind") { $r = executeGenericSQL("UPDATE fch_draft SET playerID = \"WithdrawnPick\" , position = \"X\" , status = \"W\" WHERE leagueID = " . $_GET[leagueID] . " AND overallPick = " . intval($_GET[pickID])); if ($r["status"] == 1) { echo displayResults(getReturnCode(1, "Your pick was successfully withdrawn.")); } else { echo displayResults(getReturnCode(0, "There has been an error and your pick was not withdrawn.")); } } if ($_GET["action"] == "closeDraft") { executeGenericSql("UPDATE fch_leagues SET draftStatus = \"closed\" WHERE id = {$leagueID} and season = \"{$season}\""); closeDraft($leagueID); echo displayResults(getReturnCode(1, "The draft is officially closed.")); } if (selectCount("fch_players", " WHERE playerID = \"WithdrawnPick\"") == 0) { executeGenericSQL("INSERT INTO fch_players SET playerID = \"WithdrawnPick\", schoolID = \"pc\" , season = \"{$season}\""); } if (selectCount("fch_players", " WHERE playerID = \"PassedPick\"") == 0) { executeGenericSQL("INSERT INTO fch_players SET playerID = \"PassedPick\", schoolID = \"pc\" , season = \"{$season}\""); } $leagueAdmin = getSingleton("fch_leagues", "admin_user", " WHERE id = {$leagueID} and season = \"{$season}\""); // Is user the admin? if (intval($leagueAdmin) == intval($userID)) { $userIsAdmin = true; } else { $userIsAdmin = false; } if (getSingleton("fch_leagues", "draftStatus", " WHERE id = {$leagueID} and season = \"{$season}\"") != "open") {
if ($_SESSION['clowns'] == 1) { $clownsYes = $clownsYes + 1; } else { $clownsNo = $clownsNo + 1; } $myfile = fopen("results.txt", "w"); fwrite($myfile, "{$balloonYes}\n{$balloonNo}\n{$cakeYes}\n{$cakeNo}\n{$presentsYes}\n{$presentsNo}\n{$clownsYes}\n{$clownsNo}"); $balloonNoPercent = round($balloonNo / ($balloonYes + $balloonNo) * 100, 2); $balloonYesPercent = round($balloonYes / ($balloonYes + $balloonNo) * 100, 2); $cakeNoPercent = round($cakeNo / ($cakeYes + $cakeNo) * 100, 2); $cakeYesPercent = round($cakeYes / ($cakeYes + $cakeNo) * 100, 2); $presentsNoPercent = round($presentsNo / ($presentsYes + $presentsNo) * 100, 2); $presentsYesPercent = round($presentsYes / ($presentsYes + $presentsNo) * 100, 2); $clownsNoPercent = round($clownsNo / ($clownsYes + $clownsNo) * 100, 2); $clownsYesPercent = round($clownsYes / ($clownsYes + $clownsNo) * 100, 2); displayResults(); } function displayResults() { global $balloonYes, $balloonNo, $balloonNoPercent, $balloonYesPercent, $cakeYes, $cakeNo, $cakeNoPercent, $cakeYesPercent, $presentsYes, $presentsNo, $presentsNoPercent, $presentsYesPercent, $clownsYes, $clownsNo, $clownsNoPercent, $clownsYesPercent; echo "<br></br>"; echo "<p>{$balloonYesPercent}% " . " of people like balloons.</p>"; echo "<p>{$cakeYesPercent}% of people like cake.</p>"; echo "<p>{$presentsYesPercent}% of people like presents.</p>"; echo "<p>{$clownsYesPercent}% of people like clowns.</p>"; echo "<br>"; if ($_SESSION['balloon'] == 1) { echo "<p>You like balloons.</p>"; } else { echo "<p>You don't like balloons.</p>"; }
function findSavings() { $selectItemstatement = "Select * From Item"; $itemResult = mysql_query($selectItemstatement); //Test whether the queries were successful if (!$itemResult) { $promotionItemMessage = "The retrieval of items was unsuccessful: "; } $numberItemRows = mysql_num_rows($itemResult); // Check if results turned out empty $itemMessage = ""; if ($numberItemRows == 0) { $itemMessage = "No items found in database"; } while ($row = mysql_fetch_assoc($itemResult)) { $itemNumber = $row['ItemNumber']; $retail = $row['FullRetailPrice']; $selectPromotionsForItemStatement = "Select * From PromotionItem WHERE ItemNumber = '" . $itemNumber . "'"; $promotionItemResult = mysql_query($selectPromotionsForItemStatement); //Test whether the queries were successful if (!$promotionItemResult) { $promotionItemMessage = "The retrieval of promotion items was unsuccessful: "; } $numberPromotionItemRows = mysql_num_rows($promotionItemResult); // Check if results turned out empty $promotionItemMessage = ""; if ($numberPromotionItemRows == 0) { $promotionItemMessage = "No items found in database"; } $bestPromo = "No Promotion"; $bestPrice = $retail; $difference = 0.0; $adEvent = "none"; while ($row = mysql_fetch_assoc($promotionItemResult)) { $promoCode = $row['PromoCode']; $salePrice = $row['SalePrice']; if ($salePrice < $bestPrice) { $selectAdEventsForPromotionStatement = "Select * From AdEventPromotion WHERE PromoCode = '" . $promoCode . "'"; $adEventPromotionResult = mysql_query($selectAdEventsForPromotionStatement); //Test whether the queries were successful if (!$adEventPromotionResult) { $adEventPromotionMessage = "The retrieval of promotion items was unsuccessful: "; } $numberAdEventPromotionRows = mysql_num_rows($adEventPromotionResult); // Check if results turned out empty $adEventPromotionMessage = ""; $bestPrice = $salePrice; $bestPromo = $promoCode; $difference = $retail - $bestPrice; if ($numberAdEventPromotionRows == 0) { $adEventPromotionMessage = "No items found in database"; } else { $result = mysql_fetch_assoc($adEventPromotionResult); $eventCode = $result['EventCode']; } } } $itemInfo = array("ItemNumber" => $itemNumber, "RetailPrice" => $retail, "BestPrice" => $bestPrice, "BestPromotion" => $bestPromo, "Difference" => $difference); $items[$itemNumber] = $itemInfo; $itemPrices[$itemNumber] = $difference; } $topItems = limitResultsToFifty($itemPrices); $sortedItems = sortItems($topItems); $i = 1; foreach ($sortedItems as $number) { $info = $items[$number]; $itemNumber = $info["ItemNumber"]; $retail = $info["RetailPrice"]; $bestPrice = $info["BestPrice"]; $promotion = $info["BestPromotion"]; displayResults($i, $itemNumber, $retail, $bestPrice, $promotion); $i = $i + 1; } }
</div>'; } } echo '<div id="content" class="container"> <div class="row left"> <h5 class="header col s12 light">Events ' . $fbProfile['name'] . ' is going to:</h5> </div> <div class="row"> <div class="col s12">'; $con = connect(); $stmt = $con->prepare("SELECT * FROM Events,UserEvents WHERE Events.id = UserEvents.EventID AND UserEvents.userID = ?"); $stmt->bind_param('s', $id); $stmt->execute(); $result = $stmt->get_result(); $results = array(); while ($row = $result->fetch_assoc()) { array_push($results, $row); } displayResults($results); echo '</div> </div> </div>'; } } ?> <?php require "style/footer.php"; ?> </body> </html>
$query = "SELECT id " . "FROM mantis_bug_table " . "where priority = {$PriorityHigh} " . "and severity = {$SeverityBlocking} " . "and project_id = 3 " . "and status < {$statusResolved} " . "Order by date_submitted asc;"; //print $query; openTable(); displayResults($query); $statusResolved = config_get('bug_resolved_status_threshold', null, null, 4); $query = "SELECT id " . "FROM mantis_bug_table " . "where priority = {$PriorityHigh} " . "and severity = {$SeverityBlocking} " . "and project_id = 4 " . "and status < {$statusResolved} " . "Order by date_submitted asc;"; //print $query; displayResults($query); closeTable(); ?> <br><br><center><h2> Issues submitted 2 weeks ago </h2></center> <?php $query = "SELECT id, datediff(now(), from_unixtime(date_submitted)) as s1 " . "FROM mantis_bug_table " . "where status = {$statusSubmitted} " . "HAVING \ts1 < 20 " . "Order by date_submitted asc;"; openTable(); displayResults($query); closeTable(); $statusResolved = config_get('bug_resolved_status_threshold', null, null, 9); ?> <br><br> <center><h2> Milestones in the last 2 weeks </h2></center> <br> <br> <?php $query = "SELECT id, from_unixtime(due_date) as duedate, datediff(now(), from_unixtime(due_date)) as s1 " . "FROM mantis_bug_table " . "where project_id = 9 " . "and category_id = 64 " . "and status < {$statusResolved} " . "HAVING s1 < 20 and s1 > 0 " . "Order by due_date asc;"; openTable(array("Due date")); displayResultsWithFields($query, array("duedate")); closeTable();
/** * Generates statistics * * @param int $surveyid The survey id * @param mixed $allfields * @param mixed $q2show * @param mixed $usegraph * @param string $outputType Optional - Can be xls, html or pdf - Defaults to pdf * @param string $pdfOutput Sets the target for the PDF output: DD=File download , F=Save file to local disk * @param string $statlangcode Lamguage for statistics * @param mixed $browse Show browse buttons * @return buffer */ function generate_statistics($surveyid, $allfields, $q2show = 'all', $usegraph = 0, $outputType = 'pdf', $pdfOutput = 'I', $statlangcode = null, $browse = true) { global $pdfdefaultfont, $pdffontsize; $astatdata = array(); //astatdata generates data for the output page's javascript so it can rebuild graphs on the fly //load surveytranslator helper Yii::import('application.helpers.surveytranslator_helper', true); $statisticsoutput = ""; //This string carries all the actual HTML code to print. $imagedir = Yii::app()->getConfig("imagedir"); $tempdir = Yii::app()->getConfig("tempdir"); $tempurl = Yii::app()->getConfig("tempurl"); $clang = Yii::app()->lang; $pdf = array(); //Make sure $pdf exists - it will be replaced with an object if a $pdf is actually being created // Used for getting coordinates for google maps $agmapdata = array(); //pick the best font file if font setting is 'auto' if (is_null($statlangcode)) { $statlangcode = getBaseLanguageFromSurveyID($surveyid); } else { $statlang = new Limesurvey_lang($statlangcode); } /* * this variable is used in the function shortencode() which cuts off a question/answer title * after $maxchars and shows the rest as tooltip (in html mode) */ $maxchars = 13; //we collect all the html-output within this variable $statisticsoutput = ''; /** * $outputType: html || pdf || */ /** * get/set Survey Details */ //no survey ID? -> come and get one if (!isset($surveyid)) { $surveyid = returnGlobal('sid'); } //Get an array of codes of all available languages in this survey $surveylanguagecodes = Survey::model()->findByPk($surveyid)->additionalLanguages; $surveylanguagecodes[] = Survey::model()->findByPk($surveyid)->language; $fieldmap = createFieldMap($surveyid, "full", false, false, $statlang->getlangcode()); // Set language for questions and answers to base language of this survey $language = $statlangcode; if ($q2show == 'all') { $summarySql = " SELECT gid, parent_qid, qid, type " . " FROM {{questions}} WHERE parent_qid=0" . " AND sid={$surveyid} "; $summaryRs = Yii::app()->db->createCommand($summarySql)->query()->readAll(); foreach ($summaryRs as $field) { $myField = $surveyid . "X" . $field['gid'] . "X" . $field['qid']; // Multiple choice get special treatment if ($field['type'] == "M") { $myField = "M{$myField}"; } if ($field['type'] == "P") { $myField = "P{$myField}"; } //numerical input will get special treatment (arihtmetic mean, standard derivation, ...) if ($field['type'] == "N") { $myField = "N{$myField}"; } if ($field['type'] == "|") { $myField = "|{$myField}"; } if ($field['type'] == "Q") { $myField = "Q{$myField}"; } // textfields get special treatment if ($field['type'] == "S" || $field['type'] == "T" || $field['type'] == "U") { $myField = "T{$myField}"; } //statistics for Date questions are not implemented yet. if ($field['type'] == "D") { $myField = "D{$myField}"; } if ($field['type'] == "F" || $field['type'] == "H") { //Get answers. We always use the answer code because the label might be too long elsewise $query = "SELECT code, answer FROM {{answers}} WHERE qid='" . $field['qid'] . "' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer"; $result = Yii::app()->db->createCommand($query)->query(); $counter2 = 0; //check all the answers foreach ($result->readAll() as $row) { $row = array_values($row); $myField = "{$myField}{$row[0]}"; } //$myField = "{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]"; } if ($q2show == 'all') { $summary[] = $myField; } //$allfields[]=$myField; } } else { // This gets all the 'to be shown questions' from the POST and puts these into an array if (!is_array($q2show)) { $summary = returnGlobal('summary'); } else { $summary = $q2show; } //print_r($_POST); //if $summary isn't an array we create one if (isset($summary) && !is_array($summary)) { $summary = explode("+", $summary); } } /** * pdf Config */ if ($outputType == 'pdf') { //require_once('classes/tcpdf/config/lang/eng.php'); global $l; $l['w_page'] = $statlang->gT("Page", 'unescaped'); //require_once('classes/tcpdf/mypdf.php'); Yii::import('application.libraries.admin.pdf', true); // create new PDF document $pdf = new Pdf(); $pdf->SetFont($pdfdefaultfont, '', $pdffontsize); $surveyInfo = getSurveyInfo($surveyid, $language); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('LimeSurvey'); $pdf->SetTitle('Statistic survey ' . $surveyid); $pdf->SetSubject($surveyInfo['surveyls_title']); $pdf->SetKeywords('LimeSurvey, Statistics, Survey ' . $surveyid . ''); $pdf->SetDisplayMode('fullpage', 'two'); // set header and footer fonts $pdf->setHeaderFont(array($pdfdefaultfont, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array($pdfdefaultfont, '', PDF_FONT_SIZE_DATA)); // set default header data $pdf->SetHeaderData("statistics.png", 10, $statlang->gT("Quick statistics", 'unescaped'), $statlang->gT("Survey") . " " . $surveyid . " '" . flattenText($surveyInfo['surveyls_title'], false, true, 'UTF-8') . "'"); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); } if ($outputType == 'xls') { /** * Initiate the Spreadsheet_Excel_Writer */ Yii::import('application.libraries.admin.pear.Spreadsheet.Excel.Xlswriter', true); if ($pdfOutput == 'F') { $sFileName = $tempdir . '/statistic-survey' . $surveyid . '.xls'; $workbook = new Xlswriter($sFileName); } else { $workbook = new Xlswriter(); } $workbook->setVersion(8); // Inform the module that our data will arrive as UTF-8. // Set the temporary directory to avoid PHP error messages due to open_basedir restrictions and calls to tempnam("", ...) $workbook->setTempDir($tempdir); // Inform the module that our data will arrive as UTF-8. // Set the temporary directory to avoid PHP error messages due to open_basedir restrictions and calls to tempnam("", ...) if (!empty($tempdir)) { $workbook->setTempDir($tempdir); } if ($pdfOutput != 'F') { $workbook->send('statistic-survey' . $surveyid . '.xls'); } // Creating the first worksheet $sheet =& $workbook->addWorksheet(utf8_decode('results-survey' . $surveyid)); $sheet->setInputEncoding('utf-8'); $sheet->setColumn(0, 20, 20); $separator = "~|"; /**XXX*/ } /** * Start generating */ $selects = buildSelects($allfields, $surveyid, $language); //count number of answers $query = "SELECT count(*) FROM {{survey_{$surveyid}}}"; //if incompleted answers should be filtert submitdate has to be not null if (incompleteAnsFilterState() == "inc") { $query .= " WHERE submitdate is null"; } elseif (incompleteAnsFilterState() == "filter") { $query .= " WHERE submitdate is not null"; } $result = Yii::app()->db->createCommand($query)->query(); //$total = total number of answers $row = $result->read(); $total = reset($row); //are there any filters that have to be taken care of? if (isset($selects) && $selects) { //filter incomplete answers? if (incompleteAnsFilterState() == "filter" || incompleteAnsFilterState() == "inc") { $query .= " AND "; } else { $query .= " WHERE "; } //add filter criteria to SQL $query .= implode(" AND ", $selects); } //get me some data Scotty $result = Yii::app()->db->createCommand($query)->query(); //put all results into $results $row = $result->read(); $results = reset($row); if ($total) { $percent = sprintf("%01.2f", $results / $total * 100); } switch ($outputType) { case "xls": $xlsRow = 0; $sheet->write($xlsRow, 0, $statlang->gT("Number of records in this query:", 'unescaped')); $sheet->write($xlsRow, 1, $results); ++$xlsRow; $sheet->write($xlsRow, 0, $statlang->gT("Total records in survey:", 'unescaped')); $sheet->write($xlsRow, 1, $total); if ($total) { ++$xlsRow; $sheet->write($xlsRow, 0, $statlang->gT("Percentage of total:", 'unescaped')); $sheet->write($xlsRow, 1, $percent . "%"); } break; case 'pdf': // add summary to pdf $array = array(); //$array[] = array($statlang->gT("Results"),""); $array[] = array($statlang->gT("Number of records in this query:", 'unescaped'), $results); $array[] = array($statlang->gT("Total records in survey:", 'unescaped'), $total); if ($total) { $array[] = array($statlang->gT("Percentage of total:", 'unescaped'), $percent . "%"); } $pdf->addPage('P', 'A4'); $pdf->Bookmark($pdf->delete_html($statlang->gT("Results", 'unescaped')), 0, 0); $pdf->titleintopdf($statlang->gT("Results", 'unescaped'), $statlang->gT("Survey", 'unescaped') . " " . $surveyid); $pdf->tableintopdf($array); $pdf->addPage('P', 'A4'); break; case 'html': $statisticsoutput .= "<br />\n<table class='statisticssummary' >\n" . "\t<thead><tr><th colspan='2'>" . $statlang->gT("Results") . "</th></tr></thead>\n" . "\t<tr><th >" . $statlang->gT("Number of records in this query:") . '</th>' . "<td>{$results}</td></tr>\n" . "\t<tr><th>" . $statlang->gT("Total records in survey:") . '</th>' . "<td>{$total}</td></tr>\n"; //only calculate percentage if $total is set if ($total) { $percent = sprintf("%01.2f", $results / $total * 100); $statisticsoutput .= "\t<tr><th align='right'>" . $statlang->gT("Percentage of total:") . '</th>' . "<td>{$percent}%</td></tr>\n"; } $statisticsoutput .= "</table>\n"; break; default: break; } //put everything from $selects array into a string connected by AND //This string ($sql) can then be passed on to other functions so you can //browse these results if (isset($selects) && $selects) { $sql = implode(" AND ", $selects); } elseif (!empty($newsql)) { $sql = $newsql; } if (!isset($sql) || !$sql) { $sql = "NULL"; } //only continue if we have something to output if ($results > 0) { if ($outputType == 'html' && $browse === true) { //add a buttons to browse results $statisticsoutput .= "<form action='" . Yii::app()->getController()->createUrl("admin/responses/index/surveyid/{$surveyid}") . "' method='post' target='_blank'>\n" . "\t\t<p>" . "\t\t\t<input type='submit' value='" . $statlang->gT("Browse") . "' />\n" . "\t\t\t<input type='hidden' name='sid' value='{$surveyid}' />\n" . "\t\t\t<input type='hidden' name='sql' value=\"{$sql}\" />\n" . "\t\t\t<input type='hidden' name='subaction' value='all' />\n" . "\t\t</p>" . "\t\t</form>\n"; } } //end if (results > 0) /* Show Summary results * The $summary array contains each fieldname that we want to display statistics for * * */ if (isset($summary) && $summary) { //let's run through the survey $runthrough = $summary; //START Chop up fieldname and find matching questions //loop through all selected questions foreach ($runthrough as $rt) { //Step 1: Get information about this response field (SGQA) for the summary $outputs = buildOutputList($rt, $language, $surveyid, $outputType, $sql, $statlang); $statisticsoutput .= $outputs['statisticsoutput']; //2. Collect and Display results ####################################################################### if (isset($outputs['alist']) && $outputs['alist']) { $display = displayResults($outputs, $results, $rt, $outputType, $surveyid, $sql, $usegraph, $browse, $pdf, $statlang); $statisticsoutput .= $display['statisticsoutput']; $astatdata = array_merge($astatdata, $display['astatdata']); } //end if -> collect and display results //Delete Build Outputs data unset($outputs); unset($display); } // end foreach -> loop through all questions //output if ($outputType == 'html') { $statisticsoutput .= "<br /> \n"; } } //end if -> show summary results switch ($outputType) { case 'xls': $workbook->close(); if ($pdfOutput == 'F') { return $sFileName; } else { return; } break; case 'pdf': $pdf->lastPage(); if ($pdfOutput == 'F') { // This is only used by lsrc to send an E-Mail attachment, so it gives back the filename to send and delete afterwards $pdf->Output($tempdir . "/" . $statlang->gT('Survey') . '_' . $surveyid . "_" . $surveyInfo['surveyls_title'] . '.pdf', $pdfOutput); return $tempdir . "/" . $statlang->gT('Survey') . '_' . $surveyid . "_" . $surveyInfo['surveyls_title'] . '.pdf'; } else { return $pdf->Output($statlang->gT('Survey') . '_' . $surveyid . "_" . $surveyInfo['surveyls_title'] . '.pdf', $pdfOutput); } break; case 'html': $statisticsoutput .= "<script type=\"text/javascript\" src=\"http://maps.googleapis.com/maps/api/js?sensor=false\"></script>\n" . "<script type=\"text/javascript\">var site_url='" . Yii::app()->baseUrl . "';var temppath='{$tempurl}';var imgpath='" . Yii::app()->getConfig('adminimageurl') . "';var aGMapData=" . ls_json_encode($agmapdata) . ";var aStatData=" . ls_json_encode($astatdata) . "</script>"; return $statisticsoutput; break; default: return $statisticsoutput; break; } }
break; }*/ echo "<p style = 'text-align:center'><a href='BirthYear.php'>Back</a></p>\n"; } $ShowForm = TRUE; $errorCount = 0; $Year = date("Y"); if (isset($_POST['Submit'])) { $Year = validateInput($_POST['Year'], "Birth Year"); if ($errorCount == 0) { $ShowForm = FALSE; } else { $ShowForm = TRUE; } } if ($ShowForm == TRUE) { if ($errorCount > 0) { // if there were errors echo "<p>Please re-enter the form information below.</p>\n"; } displayForm($Year); } else { displayResults($Year); } ?> </body> </html>