Ejemplo n.º 1
0
<?php

session_start();
require_once __DIR__ . '/autoload.php';
require_once __DIR__ . '/classes/simple_html_dom.php';
$ads_controller = new AdvertsController();
if (!empty($_POST['link'])) {
    $url = $_POST['link'];
    $get = @file_get_html($url);
    if (false == $get) {
        $_SESSION['errors'] = 'Invalid link!';
        header('Location: /views/ads/importAds.php');
    } else {
        $data = [];
        $data['title'] = $get->find('h1')[0]->innertext;
        $data['image'] = $get->find('img')[1]->src;
        if ($get->innertext != '' and count($get->find('.description-expanded div.item-params'))) {
            foreach ($get->find('.description-expanded  div.item-params') as $div) {
                $data['text'] .= $div->innertext;
            }
        }
        if ($get->innertext != '' and count($get->find('.description-text div#desc_text p'))) {
            foreach ($get->find('.description-text div#desc_text') as $p) {
                $data['text'] .= $p->innertext;
            }
        }
        $ads_controller->addAdvert($data);
        header('Location: /index.php');
        die;
    }
}
Ejemplo n.º 2
0
<?php

session_start();
require_once __DIR__ . '/autoload.php';
$users_controller = new UsersController();
if (!$users_controller->isAuthUser()) {
    if (!$users_controller->isNotAuthUser()) {
        $_SESSION['outh'] = false;
    } else {
        $_SESSION['outh'] = true;
    }
}
$ads_controller = new AdvertsController();
if (!isset($_GET['ads_id'])) {
    $items = $ads_controller->actionAll();
    include __DIR__ . '/views/ads/allAds.php';
} else {
    $item = $ads_controller->actionOne();
    include __DIR__ . '/views/ads/oneAd.php';
    $id = $ads_controller->getUserId()->user_id;
    $data = $users_controller->nameAndPhone($id);
    include __DIR__ . '/views/ads/addInfo.php';
}