intcast($_REQUEST['pid']); } if(!isset($pageid)) { header("location: ../error/4/"); exit; } if(isset($_POST['csrf'])) { if($_POST['csrf'] === $_SESSION['uuid']) { if(isset($_POST['count'])) { $len = $db->intcast($_POST['count']); } else { $len = 1; } for($i = 0; $i < $len; $i++) { $image = false; if(isset($_FILES['resource_'.$i]) && !empty($_FILES['resource_'.$i])) { $name = basename($_FILES['resource_'.$i]["name"]); if(!empty($name)) { if(stripos($name,'.png',-4) || stripos($name,'.jpg',-4) || stripos($name,'.gif',-4)) { if ($_FILES['resource_'.$i]['error'] == UPLOAD_ERR_OK) { $tmp_name = $_FILES['resource_'.$i]["tmp_name"]; move_uploaded_file($tmp_name, UPLOAD_DIR. "/$name"); $image = $name; } } } } $id = $db->intcast($_POST['id'.$i]); $component_title_vars = $_POST['component_title_' . $i]; $component_text_vars = $_POST['component_text_' . $i]; $table = 'components'; if($image != false) { $columns = ['component_title','component_text','component_image']; $values = [$component_title_vars,$component_text_vars,$image]; } else { $columns = ['component_title','component_text']; $values = [$component_title_vars,$component_text_vars]; } $db->update($table,$columns,$values,$id); } } } $table = 'components'; $column = 'pid'; $value = $pageid; $operator = '*'; $result = $db->select($table,$operator,$column,$value); $table = 'pages'; $column = 'id'; $value = $pageid; $operator = '*'; $result_header = $db->select($table,$operator,$column,$value); ?>