示例#1
0
$title = $arr->getTitle();
$content = $arr->getContent();
if (!empty($_POST) && isset($_POST['titleNew']) && isset($_POST['contentNew'])) {
    $titleNew = trim($_POST['titleNew']);
    $contentNew = trim($_POST['contentNew']);
    if (isset($_FILES['image'])) {
        if ($_FILES['image']['name'] != '') {
            $arrtype = array('image/jpeg', 'image/gif', 'image/png');
            if (in_array($_FILES['image']['type'], $arrtype) && $_FILES['image']['size'] < 1000000) {
                if (!is_dir("img")) {
                    mkdir("img");
                }
                if (ImageUpload::upload($link, $_FILES['image'])) {
                    $name = $_FILES['image']['name'];
                    $name = " '{$name}' ";
                    $add = ImageRepo::add($link, $name, $_GET['id']);
                    $change = true;
                }
            } else {
                $error = true;
                $error_message[] = 'Файл должен быть формата .jpg, .png или .gif и размером меньше 1Mb';
            }
        }
    }
    if (!empty($titleNew) && !empty($contentNew)) {
        if (ArticleRepo::edit($link, $_GET['id'], $_POST['titleNew'], $_POST['contentNew'])) {
            $title = $titleNew;
            $content = $contentNew;
            $change = true;
        }
    } else {