Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>"Поздравляем героя «Отеля Элеон» Костика"</title>
- <meta charset="UTF-8">
- </head>
- <body>
- <center>
- <?php
- $con = mysqli_connect('localhost','kovdos_vesti','vesti999','kovdos_vesti');
- mysqli_set_charset($con,"utf8");
- @header('Content-Type: text/html; charset=utf-8');
- $query = mysqli_query($con,'select * from `setting`');
- $row = mysqli_fetch_array($query);
- $group = $row['group'];
- $post_max_number = $row['post_max_number'];
- $comment_max_number = $row['comment_max_number'];
- $data = file_get_contents("https://api.vk.com/method/wall.get?domain=$group&count=$post_max_number");
- $json_data = json_decode($data, true);
- foreach ($json_data['response'] as $key => $value) {
- global $con;
- if (isset($value['attachment']) && $value['attachment']['type'] === 'photo') {
- $from_id = urlencode($value['from_id']);
- $post_id = urlencode($value['id']);
- $text = $value['text'];
- $img = $value['attachment']['photo']['src_big'];
- $date = date("y-m-d", $value['date']);
- $year = date("Y");
- $month = date("M", $date);
- $day = date("d");
- if (!file_exists("content/{$year}/{$month}/{$day}/posts_image")) {
- mkdir("content/{$year}/{$month}/{$day}/posts_image", 0777, true);
- }
- copy($img,"content/{$year}/{$month}/{$day}/posts_image/$post_id.jpg");
- $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')";
- $run_insert = mysqli_query($con,$insert);
- if($run_insert){
- echo"<b style='color:green;'>yes {$post_id}</b><br>";
- }
- else{
- echo"<b style='color:red;'>no</b><br>";
- }
- $getComments = file_get_contents("https://api.vk.com/method/wall.getComments?post_id=$post_id&owner_id=$from_id&count=$comment_max_number");
- $json_Comments = json_decode($getComments,true);
- foreach ($json_Comments['response'] as $key => $value) {
- $text_com = $value['text'];
- $user_id = $value['uid'];
- $url3 = file_get_contents("https://api.vk.com/method/users.get?user_ids=$user_id&fields=photo_200");
- $json_data3 = json_decode($url3,true);
- foreach ($json_data3['response'] as $key => $value2) {
- $name = $value2['first_name'];
- $image_src = $value2['photo_200'];
- $date = date ("y-m-d", $value['date']);
- }
- if (!file_exists("content/{$year}/{$month}/{$day}/photo_comments")) {
- mkdir("content/{$year}/{$month}/{$day}/photo_comments", 0777, true);
- }
- copy($img,"content/{$year}/{$month}/{$day}/photo_comments/$name.jpg");
- $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')";
- $run_insert = mysqli_query($con,$insert);
- if($run_insert){
- echo"<b style='color:green;'>yes, comment {$post_id}</b><br>";
- }
- else{
- echo"<b style='color:red;'>No, comment</b><br>";
- }
- }
- }
- }
- ?>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement