Пример #1
0
            // if everything is ok, try to upload file
        } else {
            if (move_uploaded_file($_FILES["imageToUpload"]["tmp_name"], $target_file)) {
                $message = "The file " . basename($_FILES["imageToUpload"]["name"]) . " has been uploaded.";
                //create ad and insert into database
                $ad = new Ad(NULL, $user_id, Input::get('name'), Input::get('description'), Input::get('price'), $target_file, Input::get('location'), Input::get('zip'), Input::get('make'), Input::get('model'), Input::get('size'), Input::get('condition'));
                $ad->insert();
                $message = "You have successfully submitted your ad, with new image.";
                $id = $ad->id;
            } else {
                $message = "Sorry, there was an error uploading your file.";
            }
        }
    } else {
        $ad = new Ad(Input::get('id'), $user_id, Input::get('name'), Input::get('description'), Input::get('price'), Input::get('image_url'), Input::get('location'), Input::get('zip'), Input::get('make'), Input::get('model'), Input::get('size'), Input::get('condition'));
        $ad->update();
        $message = "You have successfully updated your ad.";
        $id = $ad->id;
    }
} else {
    $id = Input::get('id');
}
if ($id != NULL) {
    $ad = new Ad($id);
    ?>

<form method="post" action="ads.edit.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php 
    echo $ad->id;
    ?>
" />
        array_push($errors, "No region selected.");
    }
    if ($p_region != '' && !preg_match('/^[0-9]{0,10}$/', $p_region)) {
        $success = false;
        array_push($errors, "The region is incorrect.");
    }
    if ('' != $p_webpage && 0 !== strpos($p_webpage, 'http://')) {
        $p_webpage = 'http://' . $p_webpage;
    }
    if ($p_webpage != '' && !preg_match('/^((http|https):\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}((:[0-9]{1,5})?\\/.*)?$/i', $p_webpage)) {
        $success = false;
        array_push($errors, "The format of webpage address is incorrect.");
    }
    if (isset($p_picture) && isset($p_picture['name']) && $p_picture['name'] != '') {
        list($postedon_year, $postedon_month, $postedon_day) = explode('-', $ad['postedon']);
        $picture_path = "{$upload_path}/{$postedon_year}/{$postedon_month}/{$postedon_day}/picture";
        $thumb_path = "{$upload_path}/{$postedon_year}/{$postedon_month}/{$postedon_day}/thumb";
        include "./admin/include/picture-upload.php";
    } else {
        $p_picture = '';
    }
    if ($success) {
        $fields = array('name' => $p_name, 'telephone' => $p_telephone, 'title' => $p_title, 'description' => $p_description, 'category' => $p_category, 'price' => $p_price, 'city' => $p_city, 'region' => $p_region, 'webpage' => $p_webpage, $g_code);
        if ($p_picture != '' || $p_del_picture > 0) {
            $fields['picture'] = $p_picture;
        }
        Ad::update($g_id, $fields);
        $ad = Ad::get_one($g_id);
    }
}
include "./templates/ad-modification.php";
Пример #3
0
}
if (isset($_GET['d'])) {
    $d = (int) $_GET['d'];
    if ($d > 0) {
        Ad::delete($d);
    }
}
if (isset($_GET['o'])) {
    $o = (int) $_GET['o'];
    $r = (int) $_GET['r'];
    if ($r != 0) {
        $r = 1;
    }
    $a['sponsored'] = $r;
    $a['sponsoredon'] = $r = 0 ? '' : date('Y-m-d', time());
    Ad::update($o, $a);
}
$tct = Ad::count();
//total count
$rpp = 10;
//row per page
$pager_options = array('mode' => 'Sliding', 'perPage' => $rpp, 'delta' => 2, 'totalItems' => $tct, 'excludeVars' => array('o', 'r', 'd', 't', 'e'));
$pager = @Pager::factory($pager_options);
list($from, $to) = $pager->getOffsetByPageId();
$ads = Ad::get_all(array(), '', $from - 1 . ", {$rpp}");
include "page-header.php";
?>

<div id="wrapper">
	
	<?php 
<?php

/**
 * Classified-ads-script
 * 
 * @copyright  Copyright (c) Szilard Szabo
 * @license    GPL v3
 * @package    Frontend
 */
include "./admin/include/common.php";
$g_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$g_code = isset($_GET['code']) ? trim(strip_tags($_GET['code'])) : '';
$ad = Ad::get_one($g_id, array('code' => $g_code, 'active' => 1));
$ad_exists = isset($ad['id']);
if ($ad_exists && isset($_POST['extension'])) {
    $success = true;
    $errors = array();
    $p_extension = (int) $_POST['extension'];
    if ($p_extension < 1) {
        $success = false;
        array_push($errors, "Please enter extension.");
    }
    if ($p_extension != '' && !preg_match('/^[0-9]{0,10}$/', $p_extension)) {
        $success = false;
        array_push($errors, "The format of extension is incorrect.");
    }
    if ($success) {
        Ad::update($g_id, array('extend' => $p_extension), $g_code);
    }
}
include "./templates/ad-extension.php";
Пример #5
0
    } catch (LengthException $e) {
        // Report any errors
        $errors[] = "Description - " . $e->getMessage();
    } catch (InvalidArgumentException $e) {
        $errors[] = "Description - " . $e->getMessage();
    }
    if ($_FILES) {
        $uploads_directory = 'img/uploads/';
        $filename = $uploads_directory . basename($_FILES['somefile']['name']);
        if (move_uploaded_file($_FILES['somefile']['tmp_name'], $filename)) {
            echo '<p>The file ' . basename($_FILES['somefile']['name']) . ' has been uploaded.</p>';
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
    if (empty($errors)) {
        // $user_id = (int)$_SESSION['user_id'];
        $ad_id = Input::get('postid');
        $new_ad = new Ad();
        $new_ad->name = $item;
        $new_ad->price = $price;
        $new_ad->image_url = $filename;
        $new_ad->description = $description;
        $new_ad->postdate = date('Y-m-d h:i');
        $new_ad->id = $ad_id;
        // $new_ad->user_id      = $user_id;
        $new_ad->update();
        header("Location: /");
        exit;
    }
}