Advertisement
Ostap34JS

Untitled

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