<?php require "../settings.php"; require_lib("docman"); # decide what to do if (isset($_POST["key"])) { switch ($_POST["key"]) { case "confirm": $OUTPUT = con_data($_POST); break; case "write": $OUTPUT = write_data($_POST); break; default: $OUTPUT = view_data($_GET); } } else { $OUTPUT = view_data($_GET); } # check department-level access # display output require "../template.php"; # enter new data function view_data($_GET) { # Get vars global $_FILES, $DOCLIB_DOCTYPES; foreach ($_GET as $key => $value) { ${$key} = $value; } # Validate input
echo "<td>" . $row['awards'] . "</td>"; echo "<td>" . $row['extra_activity'] . "</td>"; echo "<td>" . $row['other_exp'] . "</td>"; echo "<td>" . $row['access_laptop'] . "</td>"; echo "<td>" . $row['project_done'] . "</td>"; echo "<td>" . $row['project_idea'] . "</td>"; echo "<td>" . write_data($row['imag_exp']) . "</td>"; echo "<td>" . write_data($row['icici_bank']) . "</td>"; echo "<td>" . write_data($row['liv_mob']) . "</td>"; echo "<td>" . write_data($row['desg_interaction']) . "</td>"; echo "<td>" . write_data($row['desg_learning']) . "</td>"; echo "<td>" . write_data($row['grass_eng']) . "</td>"; echo "<td>" . write_data($row['perf_capture']) . "</td>"; echo "<td>" . write_data($row['desg_sustainability']) . "</td>"; echo "<td>" . write_data($row['magical_inter']) . "</td>"; echo "<td>" . write_data($row['fabrication_lab']) . "</td>"; echo "<td>" . $row['expect'] . "</td>"; echo "<td>" . $row['tech_volunteer'] . "</td>"; echo "<td>" . $row['ref1_name'] . "</td>"; echo "<td>" . $row['ref1_contact'] . "</td>"; echo "<td>" . $row['ref1_position'] . "</td>"; echo "<td>" . $row['ref1_relation'] . "</td>"; echo "<td>" . $row['ref2_name'] . "</td>"; echo "<td>" . $row['ref2_contact'] . "</td>"; echo "<td>" . $row['ref2_position'] . "</td>"; echo "<td>" . $row['ref2_relation'] . "</td>"; echo "<td>" . $row['profile_type'] . "</td>"; echo "</tr>"; } echo "</table>"; ?>
function new_entry($name, $email, $text) { global $db_name, $tbl_name, $fld_id, $fld_timestamp, $fld_name, $fld_email, $fld_text, $boxEntries, $reservedNames; $error = ''; $tstamp = date('YmdHis'); if (!is_admin() && in_array(strtolower($name), $reservedNames)) { $name = 'xxx'; } if ($db_name) { if (!get_magic_quotes_gpc()) { $name = addslashes($name); $email = addslashes($email); $text = addslashes($text); } $sql = "INSERT INTO {$tbl_name} ({$fld_timestamp}, {$fld_name}, {$fld_email}, {$fld_text}) "; $sql .= "VALUES ('{$tstamp}', '{$name}', '{$email}', '{$text}')"; if (!mysql_query($sql)) { $error = mysql_error(); } else { $sql = "SELECT {$fld_id} FROM {$tbl_name} ORDER BY {$fld_timestamp} DESC LIMIT {$boxEntries}, 1"; $result = mysql_query($sql); if (mysql_num_rows($result)) { if ($row = mysql_fetch_row($result)) { $sql = "DELETE FROM {$tbl_name} WHERE {$fld_id}<={$row['0']}"; if (!mysql_query($sql)) { $error = mysql_error(); } } } } } else { $data = read_data(); $len = count($data); $id = $len ? $data[$len - 1][0] + 1 : 1; if ($len >= $boxEntries) { array_shift($data); } $data[] = array($id, $tstamp, $name, $email, $text); write_data($data); } return $error; }
function init_sudoku() { $ch = 0; $nums = range(1, 9); shuffle($nums); while ($ch == 0) { for ($i = 0; $i < 9; $i++) { $_SESSION['sud'][$i] = array_fill(0, 9, 0); } for ($i = 0; $i < 9; $i++) { for ($j = 0; $j < 9; $j++) { $nu = 0; $vernhor = array_merge($_SESSION['sud'][$i], array($_SESSION['sud'][0][$j], $_SESSION['sud'][1][$j], $_SESSION['sud'][2][$j], $_SESSION['sud'][3][$j], $_SESSION['sud'][4][$j], $_SESSION['sud'][5][$j], $_SESSION['sud'][6][$j], $_SESSION['sud'][7][$j], $_SESSION['sud'][8][$j])); //сформируем массив значений данного квадрата $kvad = array(); $fk = floor($i / 3) * 3; $tk = $fk + 2; $fm = floor($j / 3) * 3; $tm = $fm + 2; for ($k = $fk; $k <= $tk; $k++) { for ($m = $fm; $m <= $tm; $m++) { $kvad[$nu] = $_SESSION['sud'][$k][$m]; $nu++; } } //my array_diff - сформируем массивы допустимых чисел $a1 = array(); $a2 = array(); for ($a = 0; $a < 9; $a++) { if (!in_array($nums[$a], $vernhor)) { $a1[count($a1)] = $nums[$a]; } } for ($a = 0; $a < 9; $a++) { if (!in_array($nums[$a], $kvad)) { $a2[count($a2)] = $nums[$a]; } } //my array_intersect - объединим массивы допустимых чисел (пересечение) $fin = array(); for ($a = 0; $a < count($a1); $a++) { if (in_array($a1[$a], $a2)) { $fin[count($fin)] = $a1[$a]; } } //удалим дублирующиеся значения $from = array_unique($fin); //если не осталось в массиве ни одного элемента - попытка провалена if (count($from) == 0) { $ch = -1; break; } //выберем рандомный элемент $n = mt_rand(0, count($from) - 1); $k = $from[$n]; unset($from); //засунем его в соответствующую ячейку $_SESSION['sud'][$i][$j] = $k; } if ($ch == -1) { $ch = -2; break; } } if ($ch == -2) { $ch = 0; continue; } else { $ch = 1; } } if (isset($_SESSION['use'])) { unset($_SESSION['use']); } for ($k = 0; $k < 3; $k++) { for ($l = 0; $l < 3; $l++) { if (empty($_SESSION['dop']['num'])) { $_SESSION['dop']['num'] = mt_rand(2, 5); } while (1) { $ch = 0; while ($ch == 0) { $i = mt_rand($k * 3, $k * 3 + 2); $j = mt_rand($l * 3, $l * 3 + 2); if (!isset($_SESSION['use'][$i][$j])) { $ch = 1; } else { $ch = 0; } } $_SESSION['use'][$i][$j] = 1; $_SESSION['sud'][$i][$j] = 0; $_SESSION['dop']['num']--; if ($_SESSION['dop']['num'] == 0) { break; } } } } unset($_SESSION['dop']); //ID данных для квеста /* $ids=myquery("SELECT id FROM quest_engine_data ORDER BY id DESC"); if(mysql_num_rows($ids)<0) $last_id=0; else list($last_id)=mysql_fetch_array($ids); $new_id=$last_id+1; myquery("UPDATE quest_engine_users SET par1_name='".$new_id."'");*/ write_data(); }
function deploy_option_update($option) { if (substr($option, 0, 1) == '_' || $name == 'cron') { return false; } $deploy_data = deploy_get_data(); $value = get_option($option); if (gettype($value) == 'array' || gettype($value) == 'object') { $value = serialize($value); } $deploy_data['wp_options'][$option] = $value; write_data($deploy_data, DEPLOY_DATA_FILE); }