Пример #1
0
    exit;
}
$file_info = array();
$file_info['file_info'] = $_FILES['image'];
$file_info['max_file_size'] = '10485760';
$file_info['allowed_extensions'] = array('png', 'jpg');
$msgs = AdsFactory::ValidateFile($file_info);
if ($msgs !== true) {
    $_SESSION['msgs'] = $msgs;
    header("Location: ./");
    exit;
}
$data = array("title" => $title, "description" => $description, "register_datetime" => $registration_time, "total_clicks" => 0, "url" => $url, "file_name" => $_FILES["image"]["name"]);
$types = array();
foreach ($data as $key => $value) {
    if (stripos($key, "_ID")) {
        $types[$key] = PDO::PARAM_INT;
    } else {
        $types[$key] = PDO::PARAM_STR;
    }
}
$insert_id = AdsFactory::insert("sand.ads", $data, $types);
$file_path = $insert_id . '/' . $_FILES["image"]["name"];
$tmp_name = $_FILES["image"]["tmp_name"];
$uploads = array("destination_file_path" => $file_path, "tmp_name" => $tmp_name, "seed" => false);
$r = AdsFactory::UploadFile($uploads);
if (!empty($_SESSION['userinput'])) {
    unset($_SESSION['userinput']);
}
header("location:index.php");
exit;
Пример #2
0
    {
        global $pdo_dbh;
        $q = 'select * from sand.ads where active = "1" order by id desc';
        $sth = $pdo_dbh->prepare($q);
        $sth->execute();
        $count = $sth->rowCount();
        if ($count > 0) {
            $res = array();
            for ($i = 0; $i < $count; $i++) {
                $result = $sth->fetch(PDO::FETCH_ASSOC);
                $obj = new ads($result["id"], $result["title"], $result["description"], $result["register_datetime"], $result["total_clicks"], $result["url"], $result["user_id"], $result["file_name"]);
                $res[] = $obj;
            }
            return $res;
        } else {
            return false;
        }
    }
}
$q = 'update sand.total_web_clicks
  set total_clicks = total_clicks + 1
  where id = 1';
$sth = $pdo_dbh->prepare($q);
$sth->execute();
$objs = AdsFactory::fetchAllAds();
$q = 'SELECT * FROM sand.total_web_clicks';
$sth = $pdo_dbh->prepare($q);
$sth->execute();
$result = $sth->fetch(PDO::FETCH_ASSOC);
ads::totalVisitingtime($result["total_clicks"]);
$totalclicks = ads::getTotalClick() + $result["total_clicks"];