/** * 为了便于读取,和恢复失败的表单提交(如非法值) * 每一个controller/*_add.php文件对于表单的处理,都是将$_POST先保存到$_SESSION[当前控制器名]['post']下 * 因此无论作为显示,还是编辑,还是编辑失败时保留原来提交的数据,都可以直接用post('array/path')来获得返回值 * * 接受1-2个参数,第一个是要读取的值离开$_SESSION/控制器/post的路径名 * 第二个如果定义了,则是把这个值赋与上述路径那个变量 */ function post($arrayindex) { $args = func_get_args(); $CI =& get_instance(); $controller = CONTROLLER; if (count($args) == 1) { return array_dir(CONTROLLER . '/post/' . $CI->{$controller}->id . '/' . $arrayindex); } elseif (count($args) == 2) { return array_dir(CONTROLLER . '/post/' . $CI->{$controller}->id . '/' . $arrayindex, $args[1]); } }
function board() { if ($this->input->post('partChooseSubmit')) { //刚从试卷选择界面到登分,界面获得当前大题和所属试卷信息 $q_exam_part = "SELECT \n\t\t\t\texam.id AS exam,exam.name AS name,\n\t\t\t\texam_paper.id AS exam_paper,exam_paper.is_extra_course,exam_paper.course AS course,\n\t\t\t\texam_part.id AS exam_part, exam_part.name AS part_name,\n\t\t\t\tgrade.name AS grade_name,course.name AS course_name,\n\t\t\t\texam_paper.students AS students, exam_paper.teacher_group AS teacher_group \n\t\t\tFROM \n\t\t\t\t(\n\t\t\t\t\t(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\texam_paper INNER JOIN exam ON (exam_paper.id='" . $this->input->post('exam_paper') . "' AND exam_paper.exam=exam.id AND exam_paper.is_scoring=1)\n\t\t\t\t\t\t)\n\t\t\t\t\t\tINNER JOIN exam_part ON (exam_part.id='" . $this->input->post('part') . "' AND exam_paper.id=exam_part.exam_paper)\n\t\t\t\t\t)\n\t\t\t\t\tINNER JOIN course ON exam_paper.course=course.id\n\t\t\t\t)\n\t\t\t\tINNER JOIN grade ON exam.grade=grade.id\n\t\t\tWHERE \n\t\t\t\t" . db_implode($_SESSION['teacher_group'], ' OR ', 'teacher_group'); $r_exam_part = mysql_query($q_exam_part); $_SESSION['score']['currentExam'] = mysql_fetch_array($r_exam_part); } if (is_null(array_dir('_SESSION/score/currentStudent_id_in_exam'))) { array_dir('_SESSION/score/currentStudent_id_in_exam', 1); } if ($this->input->post('nextScore') || $this->input->post('previousScore') || $this->input->post('backToPartChoose')) { $scoreData = array('student' => $_SESSION['score']['currentStudent']['student'], 'exam' => $_SESSION['score']['currentExam']['exam'], 'exam_paper' => $_SESSION['score']['currentExam']['exam_paper'], 'exam_part' => $_SESSION['score']['currentExam']['exam_part'], 'score' => $this->input->post('is_absent') ? '0' : $this->input->post('score'), 'is_absent' => $this->input->post('is_absent') ? '1' : '0', 'scorer' => $this->user->id, 'scorer_username' => $_SESSION['username'], 'time' => $this->date->now); if ($this->input->post('score') != $_SESSION['score']['currentScore']['score'] || $this->input->post('is_absent') != $_SESSION['score']['currentScore']['is_absent']) { $this->db->replace('score', $scoreData); } //当前学生-大题-分数插入数据表 if ($this->input->post('nextScore')) { $_SESSION['score']['currentStudent_id_in_exam']++; } if ($this->input->post('previousScore')) { $_SESSION['score']['currentStudent_id_in_exam']--; } if ($this->input->post('backToPartChoose')) { unset($_SESSION['score']['currentExam']); redirect('score.php'); } } if ($this->input->post('studentSearch')) { $q_student = "\n\t\t\t\tSELECT * FROM exam_student,view_student \n\t\t\t\tWHERE view_student.num='" . $this->input->post('studentNumForSearch') . "'\n\t\t\t\t\tAND exam_student.student=view_student.id\n\t\t\t\t\tAND exam_student.exam='" . $_SESSION['score']['currentExam']['exam'] . "'\n\t\t\t"; } else { $q_student = "\n\t\t\t\tSELECT * FROM\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT * \n\t\t\t\t\t\tFROM exam_student\n\t\t\t\t\t\tWHERE exam='" . $_SESSION['score']['currentExam']['exam'] . "'\n\t\t\t\t\t\tAND (" . (int) (!$_SESSION['score']['currentExam']['is_extra_course']) . " OR extra_course='" . $_SESSION['score']['currentExam']['course'] . "')\n\t\t\t\t\t\tORDER BY room, seat\n\t\t\t\t\t\tLIMIT " . ($_SESSION['score']['currentStudent_id_in_exam'] - 1) . ",1\n\t\t\t\t\t)current_exam_student\n\t\t\t\tLEFT JOIN view_student ON view_student.id = current_exam_student.student\n\t\t\t"; } $r_student = mysql_query($q_student); $_SESSION['score']['currentStudent'] = mysql_fetch_array($r_student); $q_score = "SELECT * FROM score WHERE student='" . $_SESSION['score']['currentStudent']['student'] . "' AND exam_part='" . $_SESSION['score']['currentExam']['exam_part'] . "' LIMIT 1"; $r_score = mysql_query($q_score); if (0) { $_SESSION['score']['currentScore'] = array(); } else { $_SESSION['score']['currentScore'] = mysql_fetch_array($r_score); } }
public function _home() { global $config, $user, $cache, $upload; if (_button()) { $event_id = request_var('event_id', 0); $filepath_1 = $config['events_path'] . 'tmp/'; $filepath_2 = $config['events_path'] . 'gallery/'; $filepath_3 = $filepath_1 . $event_id . '/'; $filepath_4 = $filepath_3 . 'thumbnails/'; $f = $upload->process($filepath_1, 'add_zip', 'zip'); if (!sizeof($upload->error) && $f !== false) { @set_time_limit(0); foreach ($f as $row) { $zip_folder = unzip($filepath_1 . $row['filename'], $filepath_3, true); _rm($filepath_1 . $row['filename']); } if (!empty($zip_folder)) { $zip_folder = substr($zip_folder, 0, -1); $fp = @opendir($filepath_3 . $zip_folder); while ($file = @readdir($fp)) { if (!is_level($file)) { $ftp->ftp_rename($ftp->dfolder() . 'data/tmp/' . $event_id . '/' . $zip_folder . '/' . $file, $ftp->dfolder() . 'data/tmp/' . $event_id . '/' . $file); //@rename($filepath_3 . $zip_folder . '/' . $file, $filepath_3 . $file); } } @closedir($fp); _rm($filepath_3 . $zip_folder); } if (!@file_exists($filepath_4)) { a_mkdir($ftp->dfolder() . 'data/tmp/' . $event_id, 'thumbnails'); } $footer_data = ''; $filerow_list = w(); $count_images = $img = $event_pre = 0; $check_is = w(); if (@file_exists($filepath_2 . $event_id)) { $fp = @opendir($filepath_2 . $event_id); while ($filerow = @readdir($fp)) { if (preg_match('#(\d+)\.(jpg)#is', $filerow)) { $dis = getimagesize($filepath_2 . $event_id . $filerow); $disd = intval(_decode('4e6a4177')); if (($dis[0] > $dis[1] && $dis[0] < $disd) || ($dis[1] > $dis[0] && $dis[1] < $disd)) { $check_is[] = $filerow; continue; } $event_pre++; } } @closedir($fp); if (count($check_is)) { echo lang('dis_invalid'); foreach ($check_is as $row) { echo $row . '<br />'; } exit; } $img = $event_pre; } $filerow_list = array_dir($filepath_3); array_multisort($filerow_list, SORT_ASC, SORT_NUMERIC); foreach ($filerow_list as $filerow) { if (preg_match('#(\d+)\.(jpg)#is', $filerow)) { $row = $upload->_row($filepath_3, $filerow); if (!@copy($filepath_3 . $filerow, $row['filepath'])) { continue; } $img++; $xa = $upload->resize($row, $filepath_3, $filepath_3, $img, array(600, 450), false, true, true, 'w2'); if ($xa === false) { continue; } $xb = $upload->resize($row, $filepath_3, $filepath_4, $img, array(100, 75), false, false); $insert = array( 'event_id' => (int) $event_id, 'image' => (int) $img, 'width' => (int) $xa['width'], 'height' => (int) $xa['height'], 'allow_dl' => 1 ); sql_insert('events_images', $insert); $count_images++; } elseif (preg_match('#(info)\.(txt)#is', $filerow)) { $footer_data = $filerow; } } if (!empty($footer_data) && @file_exists($filepath_3 . $footer_data)) { $footer_info = @file($filepath_3 . $footer_data); foreach ($footer_info as $linerow) { $part = explode(':', $linerow); $part = array_map('trim', $part); $numbs = explode('-', $part[0]); $numbs[1] = (isset($numbs[1])) ? $numbs[1] : $numbs[0]; for ($i = ($numbs[0] + $event_pre), $end = ($numbs[1] + $event_pre + 1); $i < $end; $i++) { $sql = 'UPDATE _events_images SET image_footer = ? WHERE event_id = ? AND image = ?'; sql_query(sql_filter($sql, htmlencode($part[1]), $event_id, $i)); } } _rm($filepath_3 . $footer_data); } $sql = 'SELECT * FROM _events_colab WHERE colab_event = ? AND colab_uid = ?'; if (!$row = sql_fieldrow(sql_filter($sql, $event_ud, $user->d('user_id')))) { $sql_insert = array( 'colab_event' => $event_id, 'colab_uid' => $user->d('user_id') ); sql_insert('events_colab', $sql_insert); } $sql = 'UPDATE _events SET images = images + ?? WHERE id = ?'; sql_query(sql_filter($sql, $count_images, $event_id)); $ftp->ftp_rename($ftp->dfolder() . 'data/tmp/' . $event_id . '/', $ftp->dfolder() . 'data/events/gallery/' . $event_id . '/'); //@rename($filepath_3, $filepath_2 . $event_id); $ftp->ftp_quit(); redirect(s_link('events', $event_id)); } _style('error', array( 'MESSAGE' => parse_error($upload->error)) ); } $sql = 'SELECT * FROM _events WHERE date < ?? ORDER BY date DESC'; $result = sql_rowset(sql_filter($sql, (time() + 86400))); foreach ($result as $row) { _style('event_list', array( 'EVENT_ID' => $row['id'], 'EVENT_TITLE' => (($row['images']) ? '* ' : '') . $row['title'], 'EVENT_DATE' => $user->format_date($row['date'])) ); } return; }