Advertisement
Guest User

Untitled

a guest
Jan 6th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.63 KB | None | 0 0
  1. <?php
  2. require_once('conf.php');
  3.  
  4. use VK\Client\VKApiClient;
  5.  
  6. $draw = new ImagickDraw();
  7.  
  8. $draw->setFillColor('white');
  9. $draw->setFont(__DIR__.'/ttf/CalibriB.ttf');
  10. $draw->setFontSize(37);
  11.  
  12. $vk = new VKApiClient();
  13. if (htmlspecialchars($_GET['pass']) == md5('pass:***')
  14.     && htmlspecialchars($_GET['task']) == "upd_count") {
  15.         $posts = $vk->wall()->get($token_ser, array(
  16.         'owner_id' => '-73015740',
  17.         'offset' => '0',
  18.         'count' => '1',
  19.         'extended' => '0',
  20.         'v' => '5.92',
  21.         ));
  22.     $cc = $posts['count']; //Количество записей
  23. }
  24.  
  25. if (htmlspecialchars($_GET['pass']) == md5('pass:***')
  26.     && htmlspecialchars($_GET['task']) == "new_user") {
  27.     $userId = htmlspecialchars($_GET['id']);
  28.     $query = "SELECT n, id, time FROM followers WHERE id = $userId";
  29.     $result = mysqli_query($link, $query);
  30.     $flag = 1;
  31.     if ($result) {
  32.         //file_put_contents("oo.txt", "$userId");
  33.         while ($row = mysqli_fetch_row($result)) {
  34.             $n = $row[0];
  35.             $flag = 0;
  36.         }
  37.  
  38.         mysqli_free_result($result);
  39.     }
  40.  
  41.     if($flag == 1) {
  42.         $user = $vk->users()->get($token_ser, array(
  43.             'user_ids' => $userId,
  44.             'lang' => 'ru',
  45.             'fields' => 'crop_photo, photo_max, first_name_nom, last_name_nom',
  46.             'v' => '5.92',
  47.         ));
  48.         //Add to database
  49.         $time = time();
  50.         $query = "INSERT INTO `groups.workjob_ufa`.`followers` (`id`, `time`) VALUES ($userId, $time);";
  51.         $result = mysqli_query($link, $query);
  52.  
  53.         $user = $user[0];
  54.         $firstname = $user['first_name_nom'];
  55.         $lastname = $user['last_name_nom'];
  56.  
  57.         if (strlen($firstname) <= 14 && strlen($lastname) <= 14) {
  58.  
  59.             $crop_photo = $user['crop_photo'];
  60.             $crop = $crop_photo['crop'];
  61.             $crop_x = $crop['x'];
  62.             $crop_y = $crop['y'];
  63.             $crop_x2 = $crop['x2'];
  64.             $crop_y2 = $crop['y2'];
  65.             $rect = $crop_photo['rect'];
  66.             $rect_x = $rect['x'];
  67.             $rect_y = $rect['y'];
  68.             $rect_x2 = $rect['x2'];
  69.             $rect_y2 = $rect['y2'];
  70.             $photo_url = $user['photo_max'];
  71. //        $photo = $crop_photo['photo'];
  72. //        $photoId = $photo['id'];
  73. //        $photo_src = $vk->photos()->getById($token_ser, array(
  74. //            'photos' => $photoId,
  75. //            'extended' => '0',
  76. //            'photo_sizes' => '0',
  77. //            'v' => '5.92',
  78. //        ));
  79.             require(__DIR__ . '/nano.php');
  80.             if ($nsfw_label == 'NSFW' && $nsfw_probability < 0.6 || $nsfw_label == 'SFW' && $nsfw_probability > 0.5) {
  81.                 $host = __DIR__ . "/images/cover/user.jpg";
  82.                 copy($photo_url, $host);
  83.                 chmod($host, 0777);
  84.  
  85.                 //Рисуем аватарку и имя
  86.                 $image = new Imagick(__DIR__ . "/images/cover/cover_orig2.jpg");
  87.                 $imageUser = new Imagick($host);
  88.  
  89.                 //Уменьшаем картинку и закругляем углы
  90.                 $imageUser->thumbnailImage(110, 110);
  91.                 $imageUser->roundCorners(110, 110);
  92.                 $image->compositeImage($imageUser, Imagick::COMPOSITE_DEFAULT, 655, 200);
  93.  
  94.                 $draw->setTextAlignment(\Imagick::ALIGN_CENTER);
  95.                 if (strlen($firstname) > 9 || strlen($lastname) > 9) $px = 809;
  96.                 $image->annotateImage($draw, 890, 250, 0, "$firstname");
  97.                 $image->annotateImage($draw, 890, 289, 0, "$lastname");
  98.  
  99.  
  100.                 $image->writeImage(__DIR__ . '/images/cover/cover_user.jpg');
  101.                
  102.             }
  103.         }
  104.     }
  105. }
  106. //Количество объявлений из бд
  107. $query = "SELECT count FROM wall_count WHERE n = 1";
  108. $result = mysqli_query($link, $query);
  109. if ($result) {
  110.     //file_put_contents("oo.txt",time());
  111.     while ($row = mysqli_fetch_row($result)) {
  112.         $count = $row[0];
  113.     }
  114.     mysqli_free_result($result);
  115. }
  116. //Рисуем дату и числа
  117. $image = new Imagick(__DIR__."/images/cover/cover_user.jpg");
  118.  
  119. setlocale(LC_ALL, 'ru_RU.UTF-8');
  120. $date = time() + 3*3600;
  121. $month = strftime("%B", $date);
  122. $day = date('d', $date);
  123. $hour = date('H', $date);
  124. $minute = date('i', $date);
  125.  
  126. $draw->setTextAlignment(\Imagick::ALIGN_LEFT);
  127. $draw->setFontSize(35);
  128. $image->annotateImage($draw, 1197, 325, 0, "$count");
  129.  
  130. $draw->setFontSize(50);
  131. $image->annotateImage($draw, 1169, 210, 0, "$hour:$minute");
  132.  
  133.  
  134. $draw->setTextAlignment(\Imagick::ALIGN_CENTER);
  135. $draw->setFontSize(33);
  136. $image->annotateImage($draw, 1230, 160, 0, "$month, $day");
  137. $image->writeImage(__DIR__.'/images/cover/cover_upload.jpg');
  138.  
  139. //Получение ссылки и загрузка изображения       
  140.  
  141.     $cover_path = dirname(__FILE__).'/images/cover/cover_upload.jpg';
  142.    
  143.    
  144.    
  145.     $post = array('photo' => new CURLFile($cover_path, 'image/jpeg', 'image0'));
  146. $upload = $vk->photos()->getOwnerCoverPhotoUploadServer($token, array(
  147.     'group_id' => $GroupId,
  148.     'crop_x2' => '1590',
  149.     'v' => '5.92',
  150.     ));
  151.  
  152.  
  153. $url = $upload['upload_url'];
  154.  
  155.     $ch = curl_init();
  156. curl_setopt($ch, CURLOPT_URL, $url);
  157. curl_setopt($ch, CURLOPT_POST, true);
  158. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  159. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  160. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  161. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  162. $result = json_decode(curl_exec($ch),true);
  163.  
  164. //Сохранение обложки
  165.  
  166. $save = $vk->photos()->saveOwnerCoverPhoto($token, array(
  167.     'hash' => $result['hash'],
  168.     'photo' => $result['photo'],
  169.     'v' => '5.92',
  170.     ));
  171. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement