function validate($fields) { foreach ($fields as $field) { if ($field['required'] == true && hasData($field['fieldName'])) { return false; } else { if (is_array($field['required'])) { foreach ($field['required'] as $requiredField) { if (!hasData($requiredField)) { return false; } } } } } return true; }
<?php session_start(); if (isset($_SESSION['last']) && $_SESSION['last'] < time() - 30) { session_unset(); } require_once "Chat2/dbcon.php"; $number = 1; while (!isset($_SESSION['userid'])) { $username = $number; $getUser = "******"; if (!hasData($getUser)) { $now = time(); $postUsers = "INSERT INTO chat_users (\n\t\t\t\tid,\n\t\t\t\tusername,\n\t\t\t\tstatus,\n\t\t\t\ttime_mod\n\t\t\t\t)\n\t\t\tVALUES (\n\t\t\t\tNULL, '{$username}', '1', '{$now}'\n\t\t\t)"; $insertUser = "******"; mysql_query($postUsers); mysql_query($insertUser); $_SESSION['userid'] = $username; $_SESSION['last'] = time(); } else { $number++; } } $roomResults = mysql_query("SELECT * FROM chat_rooms WHERE name = 'Parlor'"); while ($rooms = mysql_fetch_array($roomResults)) { $file = $rooms['file']; } ?> <!DOCTYPE html> <html>
session_start(); require_once "../chat/dbcon.php"; if (isAjax()) { $data = array(); $username = cleanInput($_POST['userid']); if (checkVar($username)) { $getUsers = "SELECT *\n \t\t\t\t\t FROM chat_users\n \t\t\t\t\t WHERE username = '******'"; if (!hasData($getUsers)) { $data['result'] = "<div class='message success'>Great! You found a username not in use</div>"; $data['inuse'] = "notinuse"; } else { $data['result'] = "<div class='message warning'>That username is already in use. (Usernames take 2 minutes without use to expire)</div>"; $data['inuse'] = "inuse"; } echo json_encode($data); } } else { $username = cleanInput($_POST['userid']); if (checkVar($username)) { $getUsers = "SELECT *\n \t\t\t\t\t FROM chat_users\n \t\t\t\t\t WHERE username = '******'"; if (!hasData($getUsers)) { $now = time(); $postUsers = "INSERT INTO `chat_users` (\n \t\t\t\t\t`id` ,\n \t\t\t\t\t`username` ,\n \t\t\t\t\t`status` ,\n \t\t\t\t\t`time_mod`\n \t\t\t\t\t)\n \t\t\t\t\tVALUES (\n \t\t\t\t\tNULL , '{$username}', '1', '{$now}'\n \t\t\t\t\t)"; mysql_query($postUsers); $_SESSION['userid'] = $username; header('Location: ./chatrooms.php'); } else { header('Location: ./?error=1'); } } }
require_once "../dbcon.php"; //Start Array $data = array(); // Get data to work with $current = cleanInput($_GET['current']); $room = cleanInput($_GET['room']); $username = cleanInput($_GET['username']); $now = time(); // INSERT your data (if is not already there) $findUser = "******"; if (!hasData($findUser)) { $insertUser = "******"; mysql_query($insertUser) or die(mysql_error()); } $findUser2 = "SELECT * FROM `chat_users` WHERE `username` = '{$username}'"; if (!hasData($findUser2)) { $insertUser2 = "INSERT INTO `chat_users` (`id` ,`username` , `status` ,`time_mod`)\n\t\t\t\t\tVALUES (NULL , '{$username}', '1', '{$now}')"; mysql_query($insertUser2); $data['check'] = 'true'; } $finish = time() + 7; $getRoomUsers = mysql_query("SELECT * FROM `chat_users_rooms` WHERE `room` = '{$room}'"); $check = mysql_num_rows($getRoomUsers); while (true) { usleep(10000); mysql_query("UPDATE `chat_users` SET `time_mod` = '{$now}' WHERE `username` = '{$username}'"); $olduser = time() - 5; $eraseuser = time() - 30; mysql_query("DELETE FROM `chat_users_rooms` WHERE `mod_time` < '{$olduser}'"); mysql_query("DELETE FROM `chat_users` WHERE `time_mod` < '{$eraseuser}'"); $check = mysql_num_rows(mysql_query("SELECT * FROM `chat_users_rooms` WHERE `room` = '{$room}' "));
function pdf_draw_graph($name, $gds, $bds = null, $label_func = null) { global $g_start, $g_end, $g_canvas; if (!hasData($gds)) { //debug(" ! Not displaying graph $name because there was no data"); $graph = $g_canvas->startGraph($name, new Range(0, 1), new Range(0, 1)); $graph->drawLegends($gds); $graph->setInvalid("No data"); pdf_draw_invalid($graph); } else { $x_range = new Range($g_start * 1000, $g_end * 1000); $max_gd = get_largest_data($gds); $max_y = $max_gd->max + 0.05 * $max_gd->max; $y_range = new Range(0, 1); $yincrement = 0.25; if ($max_y > 0) { $yincrement = calcYIncrement($max_y); $new_max = $yincrement; while ($new_max < $max_y) { $new_max += $yincrement; } $max_y = $new_max; $y_range = new Range(0, $max_y); } if ($label_func) { $yincrement = 1; } $graph = $g_canvas->startGraph($name, $x_range, $y_range); pdf_draw_graph_blocks($graph, $bds); setup_graph($graph, $name, $x_range, $y_range, $yincrement, true, $label_func); pdf_draw_graph_lines($graph, $gds); $graph->drawLegends($gds, $bds); } $graph->end(); }
function getUploadData() { assert(true === hasData()); //Do not call this function before hasData() if (isset($_POST['upload_data'])) { return (string) $_POST['upload_data']; //be happy PHP does COW'ing and string deduplication behind the scene... } elseif (is_string($_FILES['upload_data']['tmp_name'])) { $fp = fopen($_FILES['upload_data']['tmp_name'], 'rb'); assert(false !== $fp); return $fp; //up to the caller to fclose(); ... } else { throw new LogicException('getUploadData failed to find the data!'); } }
$ddeInstruments = $config->getSetting('DoubleDataEntryInstruments'); $dataDir = "logs"; $diff = null; $commentids = array(); //Check to see if the variable instrument is set if ($instrument == 'all' || $instrument == 'All') { $instruments = Utility::getAllInstruments(); } else { $instruments = array($instrument => $instrument); } //get all candidates $candidates = $DB->pselect("SELECT CandID, PSCID FROM candidate", array()); //get all subprojectids $subprojectids = $DB->pselect("SELECT DISTINCT subprojectid FROM session", array()); foreach ($instruments as $instrument => $full_name) { if (isset($instrument) && hasData($instrument)) { print "instrument is {$instrument} \n"; $commentids = array(); foreach ($candidates as $candidate) { $candid = $candidate['CandID']; $pscid = $candidate['PSCID']; foreach ($subprojectids as $subprojectid) { $session_info = $DB->pselectRow("SELECT DISTINCT s.Visit_label,s.ID from session s\n JOIN candidate c on (c.candid=s.candid)\n JOIN flag f on (f.sessionid=s.id)\n WHERE s.candID = :cid AND f.test_name = :fname AND\n s.subprojectid = :subid", array('cid' => $candid, 'fname' => $instrument, 'subid' => $subprojectid['subprojectid'])); if ($session_info != null && !empty($session_info)) { $sessionid = $session_info['ID']; $visit_label = $session_info['Visit_label']; if ($sessionid != null) { $commentid = getCommentIDs($instrument, $visit_label, $sessionid, $candid, $pscid, $subprojectid['subprojectid']); $size = sizeof($commentid); if ($size >= 2) { $commentids[] = $commentid;