save_image_order($connection); break; case 6: save_section_order($connection); break; case 7: save_section($connection); break; case 8: save_youtube($connection); break; case 9: save_image($connection); break; case 10: add_section($connection); break; case 11: add_youtube($connection); break; case 12: add_image($connection); break; default: print '[["ERROR"]["Save had an invalid ID"]]'; } } /* Navigation items */ // Add items function add_section_item($id, $is_sub, $content, $connection) {
protected function add() { global $db; $params = array(); if ($this->method == "POST") { if (sizeof($this->args) > 0) { $type = $this->args[0]; if ($type == "subject") { if (sizeof($this->args) == 6) { $params["sid"] = $this->args[1]; $params["sname"] = $this->args[2]; $params["order"] = $this->args[3]; $params["about"] = $this->args[4]; $params["notation"] = $this->args[5]; return add_subject($db, $params); } else { return "It seems you want to add a subject, but have passed in the wrong number of parameters!"; } } else { if ($type == "topic") { if (sizeof($this->args) == 6) { $params["tid"] = $this->args[1]; $params["tname"] = $this->args[2]; $params["order"] = $this->args[3]; $params["sid"] = $this->args[4]; $params["about"] = $this->args[5]; return add_topic($db, $params); } else { return "It seems you want to add a topic, but have passed in the wrong number of parameters!"; } } else { if ($type == "section") { if (sizeof($this->args) == 7) { $params["section_id"] = $this->args[1]; $params["section_name"] = $this->args[2]; $params["order"] = $this->args[3]; $params["tid"] = $this->args[4]; $params["title"] = $this->args[5]; $params["content"] = $this->args[5]; return add_section($db, $params); } else { return "It seems you want to add a section, but have passed in the wrong number of parameters!"; } } else { if ($type == "example") { if (sizeof($this->args) == 7) { $params["eid"] = $this->args[1]; $params["ename"] = $this->args[2]; $params["order"] = $this->args[3]; $params["section_id"] = $this->args[4]; $params["problem"] = $this->args[5]; $params["solution"] = $this->args[5]; return add_example($db, $params); } else { return "It seems you want to add an example, but have passed in the wrong number of parameters!"; } } else { return "No such object exists in the database!"; } } } } } else { return "No parameters were provided!"; } } else { return "This only accepts POST requests!"; } }
$conn = connect(); insert('course', array('code', 'title', 'unit', 'req', 'des'), array(array($content[0], $content[1], $content[2], $content[3], $content[4]))); } function add_section($content) { $conn = connect(); $tname = substr($content[0], 0, 4); //check_table($tname); for ($i = 0; $i < count($content[5]); $i++) { for ($j = 0; $j < count($content[5][$i][0]); $j++) { if ($content[5][$i][0][$j][0] == '') { break; } insert('schedule', array('code', 'subcode', 'place', 'session', 'person'), array(array($content[0], $content[5][$i][0][$j][0], $content[5][$i][0][$j][1], $content[5][$i][0][$j][2], $content[5][$i][0][$j][3]))); } for ($j = 0; $j < count($content[5][$i][1]); $j++) { if ($content[5][$i][1][$j][0] == '') { break; } insert('schedule', array('code', 'subcode', 'place', 'session', 'person'), array(array($content[0], $content[5][$i][1][$j][0], $content[5][$i][1][$j][1], $content[5][$i][1][$j][2], $content[5][$i][1][$j][3]))); } $num++; } } if ($_SERVER["REQUEST_METHOD"] == "POST") { //$file = fopen("data/".time().".txt","w+"); $temp1 = file_get_contents('php://input'); $temp = json_decode($temp1, true); add_course($temp); add_section($temp); }
$_SESSION['section_selected'] = $section_name; $_SESSION['video_selected'] = $video_id; } if (isset($_GET["section"]) && !isset($_GET["video"])) { $section_name = $_GET["section"]; $_SESSION['section_selected'] = $section_name; } if (isset($_POST['submit']) || isset($_SESSION['course_id'])) { if (isset($_POST['course_id'])) { $_SESSION['course_id'] = $_POST['course_id']; } if (isset($_POST['section_name'])) { //echo "hello"; $course_id = $_SESSION['course_id']; $course_name = fetch_course_name($course_id); $result = add_section($course_name, $_POST['section_name'], $_POST['section_position']); if ($result) { echo "Section added"; } else { echo "section add failed"; } } if (isset($_FILES['video']) && $_SESSION['section_selected']) { $section_selected = $_SESSION['section_selected']; $arr = explode('_', $section_selected); $section_selected = $arr[0]; echo $section_selected; $course_id = $_SESSION['course_id']; $course_name = fetch_course_name($course_id); $video_link = upload_video($course_name, $section_selected); //echo $video_link;