Example #1
0
 // Validate status
 if (!empty($_POST['status']) && in_array($_POST['status'], array('published', 'draft'))) {
     $data['status'] = $_POST['status'];
 } else {
     $errors['status'] = "You didn't provide a valid status";
 }
 // Validate title
 if (!empty($_POST['title']) && !ctype_space($_POST['title'])) {
     $data['title'] = htmlspecialchars(trim($_POST['title']));
 } else {
     $errors['title'] = "You didn't enter a valid title";
 }
 // Validate slug
 if (!empty($_POST['slug']) && !ctype_space($_POST['slug'])) {
     $slug = Functions::CreateSlug(trim($_POST['slug']));
     if ($slug == $page->slug || !Page::IsReserved($slug) && !Page::Exist(array('slug' => $slug))) {
         $data['slug'] = $slug;
     } else {
         $errors['slug'] = "URL is not available";
     }
 } else {
     $errors['slug'] = "You didn't enter a valid URL";
 }
 // Validate content
 if (!empty($_POST['content']) && !ctype_space($_POST['content'])) {
     $data['content'] = trim($_POST['content']);
 } else {
     $data['content'] = '';
 }
 // Update record if no errors were found
 if (empty($errors)) {
Example #2
0
        $slug = Functions::CreateSlug(trim($_POST['slug']));
    } else {
        if ($_POST['action'] == 'title') {
            $slug = Functions::CreateSlug(trim($_POST['title']));
        } else {
            App::Throw404();
        }
    }
} else {
    App::Throw404();
}
// Validate Page ID
if (isset($_POST['page_id']) && $_POST['page_id'] == 0) {
    $page_id = 0;
} else {
    if (!empty($_POST['page_id']) && is_numeric($_POST['page_id']) && Page::Exist(array('page_id' => $_POST['page_id']))) {
        $page_id = $_POST['page_id'];
    } else {
        App::Throw404();
    }
}
$slug_page_id = Page::Exist(array('slug' => $slug));
// If reserved
// If create & taken
// If update and & taken
if (Page::IsReserved($slug) || $slug_page_id && $slug_page_id !== $page_id) {
    echo json_encode(array('result' => 0, 'msg' => Page::GetAvailableSlug($slug)));
} else {
    // OK
    echo json_encode(array('result' => 1, 'msg' => $slug));
}
Example #3
0
 // Validate status
 if (!empty($_POST['status']) && in_array($_POST['status'], array('published', 'draft'))) {
     $data['status'] = $_POST['status'];
 } else {
     $errors['status'] = "You didn't provide a valid status";
 }
 // Validate title
 if (!empty($_POST['title']) && !ctype_space($_POST['title'])) {
     $data['title'] = htmlspecialchars(trim($_POST['title']));
 } else {
     $errors['title'] = "You didn't enter a valid title";
 }
 // Validate slug
 if (!empty($_POST['slug']) && !ctype_space($_POST['slug'])) {
     $slug = Functions::CreateSlug(trim($_POST['slug']));
     if (!Page::IsReserved($slug) && !Page::Exist(array('slug' => $slug))) {
         $data['slug'] = $slug;
     } else {
         $errors['slug'] = "URL is not available";
     }
 } else {
     $errors['slug'] = "You didn't enter a valid URL";
 }
 // Validate content
 if (!empty($_POST['content']) && !ctype_space($_POST['content'])) {
     $data['content'] = trim($_POST['content']);
 } else {
     $data['content'] = '';
 }
 // Create page if no errors were found
 if (empty($errors)) {