Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //header('Content-type: image/jpg');
- require_once('conf.php');
- use VK\Client\VKApiClient;
- $flag_draw_user = 0;
- //$image->readImage('/images/cover/cover_orig.jpg');
- //$image->thumbnailImage(795, 0);
- //Настройки для чисел (комменты и смартфоны)
- //$draw->setFillColor('white');
- //$draw->setFont('Roboto-Medium.ttf');
- //$draw->setFontSize( 29 );
- $draw = new ImagickDraw();
- $draw->setFillColor('white');
- $draw->setFont(__DIR__.'/ttf/CalibriB.ttf');
- $draw->setFontSize(37);
- $vk = new VKApiClient();
- if (htmlspecialchars($_GET['pass']) == md5('pass:Zhjckfd12')
- && htmlspecialchars($_GET['task']) == "upd_count") {
- $posts = $vk->wall()->get($token_ser, array(
- 'owner_id' => '-73015740',
- 'offset' => '0',
- 'count' => '1',
- 'extended' => '0',
- 'v' => '5.92',
- ));
- $cc = $posts['count']; //Количество записей
- }
- if (htmlspecialchars($_GET['pass']) == md5('pass:Zhjckfd12')
- && htmlspecialchars($_GET['task']) == "new_user") {
- $userId = htmlspecialchars($_GET['id']);
- $query = "SELECT n, id, time FROM followers WHERE id = $userId";
- $result = mysqli_query($link, $query);
- $flag = 1;
- if ($result) {
- //file_put_contents("oo.txt", "$userId");
- while ($row = mysqli_fetch_row($result)) {
- $n = $row[0];
- $flag = 0;
- }
- mysqli_free_result($result);
- }
- if($flag == 1) {
- $user = $vk->users()->get($token_ser, array(
- 'user_ids' => $userId,
- 'lang' => 'ru',
- 'fields' => 'crop_photo, photo_max, first_name_nom, last_name_nom, photo_604',
- 'v' => '5.92',
- ));
- //Add to database
- $time = time();
- $query = "INSERT INTO `groups.workjob_ufa`.`followers` (`id`, `time`) VALUES ($userId, $time);";
- $result = mysqli_query($link, $query);
- $user = $user[0];
- $firstname = $user['first_name_nom'];
- $lastname = $user['last_name_nom'];
- if (strlen($firstname) <= 14 && strlen($lastname) <= 14) {
- $crop_photo = $user['crop_photo'];
- $crop = $crop_photo['crop'];
- $crop_x = $crop['x'];
- $crop_y = $crop['y'];
- $crop_x2 = $crop['x2'];
- $crop_y2 = $crop['y2'];
- $rect = $crop_photo['rect'];
- $rect_x = $rect['x'];
- $rect_y = $rect['y'];
- $rect_x2 = $rect['x2'];
- $rect_y2 = $rect['y2'];
- $photo_url = $user['photo_max'];
- // $photo = $crop_photo['photo'];
- // $photoId = $photo['id'];
- // $photo_src = $vk->photos()->getById($token_ser, array(
- // 'photos' => $photoId,
- // 'extended' => '0',
- // 'photo_sizes' => '0',
- // 'v' => '5.92',
- // ));
- require(__DIR__ . '/nano.php');
- if ($nsfw_label == 'NSFW' && $nsfw_probability < 0.6 || $nsfw_label == 'SFW' && $nsfw_probability > 0.5) {
- $host = __DIR__ . "/images/cover/user.jpg";
- copy($photo_url, $host);
- chmod($host, 0777);
- //Рисуем аватарку и имя
- $image = new Imagick(__DIR__ . "/images/cover/cover_orig2.jpg");
- $imageUser = new Imagick($host);
- //Уменьшаем картинку и закругляем углы
- $imageUser->thumbnailImage(110, 110);
- $imageUser->roundCorners(110, 110);
- $image->compositeImage($imageUser, Imagick::COMPOSITE_DEFAULT, 655, 200);
- $draw->setTextAlignment(\Imagick::ALIGN_CENTER);
- if (strlen($firstname) > 9 || strlen($lastname) > 9) $px = 809;
- $image->annotateImage($draw, 890, 250, 0, "$firstname");
- $image->annotateImage($draw, 890, 289, 0, "$lastname");
- $image->writeImage(__DIR__ . '/images/cover/cover_user.jpg');
- }
- }
- }
- }
- //Количество объявлений из бд
- $query = "SELECT count FROM wall_count WHERE n = 1";
- $result = mysqli_query($link, $query);
- if ($result) {
- //file_put_contents("oo.txt",time());
- while ($row = mysqli_fetch_row($result)) {
- $count = $row[0];
- }
- mysqli_free_result($result);
- }
- //Рисуем дату и числа
- $image = new Imagick(__DIR__."/images/cover/cover_user.jpg");
- setlocale(LC_ALL, 'ru_RU.UTF-8');
- $date = time() + 3*3600;
- $month = strftime("%B", $date);
- $day = date('d', $date);
- $hour = date('H', $date);
- $minute = date('i', $date);
- $draw->setTextAlignment(\Imagick::ALIGN_LEFT);
- $draw->setFontSize(35);
- $image->annotateImage($draw, 1197, 325, 0, "$count");
- $draw->setFontSize(50);
- $image->annotateImage($draw, 1169, 210, 0, "$hour:$minute");
- $draw->setTextAlignment(\Imagick::ALIGN_CENTER);
- $draw->setFontSize(33);
- $image->annotateImage($draw, 1230, 160, 0, "$month, $day");
- $image->writeImage(__DIR__.'/images/cover/cover_upload.jpg');
- //Получение ссылки и загрузка изображения
- $cover_path = dirname(__FILE__).'/images/cover/cover_upload.jpg';
- $post = array('photo' => new CURLFile($cover_path, 'image/jpeg', 'image0'));
- $upload = $vk->photos()->getOwnerCoverPhotoUploadServer($token, array(
- 'group_id' => $GroupId,
- 'crop_x2' => '1590',
- 'v' => '5.92',
- ));
- $url = $upload['upload_url'];
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
- $result = json_decode(curl_exec($ch),true);
- //Сохранение обложки
- $save = $vk->photos()->saveOwnerCoverPhoto($token, array(
- 'hash' => $result['hash'],
- 'photo' => $result['photo'],
- 'v' => '5.92',
- ));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement