Advertisement
Ostap34JS

Untitled

Mar 13th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.14 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>"Поздравляем героя «Отеля Элеон» Костика"</title>
  5.         <meta charset="UTF-8">
  6.     </head>
  7.     <body>
  8.         <center>
  9.             <?php
  10.             $con = mysqli_connect('localhost','kovdos_vesti','vesti999','kovdos_vesti');
  11.  
  12.             mysqli_set_charset($con,"utf8");
  13.  
  14.             @header('Content-Type: text/html; charset=utf-8');
  15.  
  16.             $query = mysqli_query($con,'select * from `setting`');
  17.             $row = mysqli_fetch_array($query);
  18.  
  19.             $group = $row['group'];
  20.  
  21.             $post_max_number = $row['post_max_number'];
  22.             $comment_max_number = $row['comment_max_number'];
  23.  
  24.            
  25.             $data = file_get_contents("https://api.vk.com/method/wall.get?domain=$group&count=$post_max_number");
  26.             $json_data = json_decode($data, true);
  27.  
  28.  
  29.             foreach ($json_data['response'] as $key => $value) {
  30.                 global $con;
  31.                 if (isset($value['attachment']) && $value['attachment']['type'] === 'photo') {
  32.  
  33.                     $from_id = urlencode($value['from_id']);
  34.  
  35.                     $post_id = urlencode($value['id']);
  36.  
  37.  
  38.                     $text = $value['text'];
  39.  
  40.                     $img = $value['attachment']['photo']['src_big'];
  41.  
  42.                     $date = date("y-m-d", $value['date']);
  43.  
  44.                     $year = date("Y");
  45.                     $month = date("M", $date);
  46.                     $day = date("d");
  47.  
  48.  
  49.                     if (!file_exists("content/{$year}/{$month}/{$day}/posts_image")) {
  50.                         mkdir("content/{$year}/{$month}/{$day}/posts_image", 0777, true);
  51.                     }
  52.  
  53.  
  54.                     copy($img,"content/{$year}/{$month}/{$day}/posts_image/$post_id.jpg");
  55.  
  56.                     $insert = "insert into `posts` (post_id,post_id2,post_text,post_author,post_image,post_date) values (null,'$post_id','$text','admin','$post_id.jpg','$date')";
  57.                     $run_insert = mysqli_query($con,$insert);
  58.                     if($run_insert){
  59.                         echo"<b style='color:green;'>yes {$post_id}</b><br>";
  60.                     }
  61.                     else{
  62.                         echo"<b style='color:red;'>no</b><br>";
  63.                     }
  64.  
  65.                     $getComments = file_get_contents("https://api.vk.com/method/wall.getComments?post_id=$post_id&owner_id=$from_id&count=$comment_max_number");
  66.  
  67.                     $json_Comments = json_decode($getComments,true);
  68.  
  69.                     foreach ($json_Comments['response'] as $key => $value) {
  70.  
  71.                         $text_com = $value['text'];
  72.                         $user_id = $value['uid'];
  73.  
  74.                         $url3 = file_get_contents("https://api.vk.com/method/users.get?user_ids=$user_id&fields=photo_200");
  75.  
  76.                         $json_data3 = json_decode($url3,true);
  77.  
  78.  
  79.                         foreach ($json_data3['response'] as $key => $value2) {
  80.                             $name = $value2['first_name'];
  81.                             $image_src = $value2['photo_200'];
  82.                             $date = date ("y-m-d", $value['date']);
  83.                         }
  84.  
  85.                         if (!file_exists("content/{$year}/{$month}/{$day}/photo_comments")) {
  86.                             mkdir("content/{$year}/{$month}/{$day}/photo_comments", 0777, true);
  87.                         }
  88.  
  89.                         copy($img,"content/{$year}/{$month}/{$day}/photo_comments/$name.jpg");
  90.  
  91.                         $insert = "insert into `comments` (com_id,post_id,com_text,com_author,user_image,post_date) values (null,'$post_id','$text_com','$name','$name.jpg','$date')";
  92.                         $run_insert = mysqli_query($con,$insert);
  93.                         if($run_insert){
  94.                             echo"<b style='color:green;'>yes, comment {$post_id}</b><br>";
  95.                         }
  96.                         else{
  97.                             echo"<b style='color:red;'>No, comment</b><br>";
  98.                         }
  99.                     }
  100.                 }
  101.             }
  102.             ?>
  103.         </center>
  104.     </body>
  105. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement