$story_seo = str_replace(" ", "-", strtolower($story_name));
    $smallimage = $_FILES['story_image'];
    if ($smallimage['name'] == "") {
        $story_image = $_REQUEST['prev_image'];
    } else {
        $story_image = $smallimage['name'];
    }
    if (!$smallimage['error']) {
        if (!@move_uploaded_file($smallimage['tmp_name'], "../stories/story_images/" . $smallimage['name'])) {
            header("location:edit-story.php?err=Unknown Error Occured please try again&id={$story_id}");
            exit;
        } else {
            $work = new ImgResizer("teachers/" . $smallimage['name']);
        }
    }
    updateStory($story_id, $story_name, $story_code, $story_description, $story_image, $story_title, $meta_tag_keyword, $meta_tag_description, rtrim($story_seo, "-"));
    header("location:stories.php");
} else {
    header("stories.php");
}
class ImgResizer
{
    var $originalFile = '';
    function ImgResizer($originalFile = '')
    {
        $this->originalFile = $originalFile;
    }
    function resize($newWidth, $targetFile)
    {
        if (empty($newWidth) || empty($targetFile)) {
            return false;
Exemple #2
0
function processAddEdit()
{
    //print_r($_POST);
    $storyID = $_POST['storyID'];
    $mode = $_POST['Mode'];
    $headline = $_POST['Headline'];
    $section = $_POST['Section'];
    $writer = $_POST['Writer'];
    $story = $_POST['Story'];
    $storyImage = $_POST['StoryImage'];
    if (isset($_POST['TopStory'])) {
        $topStory = 'Y';
    } else {
        $topStory = 'N';
    }
    $datePublished = $_POST['DatePublished'];
    // Validation
    $errors = "";
    if (empty($headline) || strlen($headline) > 100) {
        $errors .= "\\n* A Headline is required and can not be longer than 100 Characters.";
    }
    if (empty($section) || strlen($section) > 20) {
        $errors .= "\\n* A Section of the Paper is required and must be no more than 20 characters.";
    }
    if (empty($writer) || strlen($writer) > 100) {
        $errors .= "\\n* A Writers Name is reuqired";
    }
    if (empty($story) || strlen($story) > 65000) {
        $errors .= "\\n* The story must be copied in and can not be more than 65000 characters";
    }
    if (empty($storyImage) || strlen($storyImage) > 75) {
        $errors .= "\\n* Please Enter just the image name and extenstion ie. GenericPic.jpg";
    }
    if (!empty($datePublished) && !strtotime($datePublished)) {
        $errors .= "\\n* Please Enter a Real Date";
    }
    if ($errors != "") {
        include '../view/newStory.php';
    } else {
        if ($mode == "add") {
            $storyID = insertStory($headline, $section, $writer, $story, $storyImage, $topStory, $datePublished);
        } else {
            $rowsAffected = updateStory($storyID, $headline, $section, $writer, $story, $storyImage, $topStory, $datePublished);
        }
        header("Location:../controller/controller.php?action=DisplayStory&StoryId={$storyID}");
    }
}