Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function download($link)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $link);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $output = curl_exec($ch);
- curl_close($ch);
- return $output;
- }
- include('cfg.php');
- $db = new mysqli($mysql_hostname, $mysql_username, $mysql_password, $mysql_dbname);
- $gid = $_GET['gid'];
- $aid = $_GET['aid'];
- $offset = 0;
- $cnt = 0;
- while (1)
- {
- $contents = download('https://api.vk.com/method/photos.get?owner_id=-'.$gid.'&album_id='.$aid.'&offset='.$offset);
- $contents = json_decode($contents, true);
- $input = $contents['response'];
- if (count($input) == 0)
- break;
- for ($i=0; $i<count($input); $i++)
- {
- $pid = $input[$i]['pid'];
- $user_id = $input[$i]['user_id'];
- if ($user_id == 100)
- continue;
- $group_id = $gid;
- $src = $input[$i]['src_big'];
- if (isset($input[$i]['src_xbig']))
- $src = $input[$i]['src_xbig'];
- if (isset($input[$i]['src_xxbig']))
- $src = $input[$i]['src_xxbig'];
- $stmt = $db->prepare("INSERT INTO main VALUES(?,?,?,?)");
- $stmt->bind_param('ddds', $pid, $user_id, $group_id, $src);
- $stmt->execute();
- $stmt->close();
- echo $cnt."<br>";
- $cnt++;
- }
- $offset += count($input);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement