Файл: import.php
Строк: 284
<?php
include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';
require H.'sys/inc/classes/class.OAuth.php';
// ID вашего приложения
$client_id = '5215455';
// Секрет ключь приложения
$client_secret = 'Re9kmNPk4nsKgUUkhx8B';
// URL cкрипта
$redirect_url = text('http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']);
// Текст поиска по умолчанию
$default_text = '';
// Результатов на страницу
$default_count = 10;
$text = (isset($_GET['q']) ? text($_GET['q']) : $default_text);
$ank = @mysql_fetch_array(mysql_query("SELECT ank_name, ank_family FROM user ORDER BY RAND() LIMIT 1"));
$text = $ank[mt_rand(0, 1)];
$page = (isset($_GET['page']) ? (int) $_GET['page'] : 1);
$offset = 0;
if ($page != 0) {
$offset = ceil($default_count * $page - $default_count);
}
// Токен для запросов
$token = false;
if (is_file(H.'sys/tmp/access_token.ta')) {
$token = @file_get_contents(H.'sys/tmp/access_token.ta');
}
// Настройки из конфига
$settings = array(
'vk' => array('client_id' => $client_id,'client_secret' => $client_secret),
'redirect_url' => $redirect_url,
);
$init = new OAuth($settings,$token);
if (isset($_GET['code'])) {
$token = $init->getToken();
if (isset($token['access_token'])) {
file_put_contents(H.'sys/tmp/access_token.ta',$token['access_token']);
header('Location: ?');
exit;
} else {
die('Не удалось получить права');
}
}
include_once 'sys/inc/thead.php';
title();
err();
// Получение токена если его нет
if (!$token) {
$link = $init->getLink('offline');
?>
<div class="mess">
<h3>Данные для приложения</h3>
Redirect_URI: <span style="color: red;"><?php echo $redirect_url; ?></span><br />
Если вы создали приложение,и прописали данные в config.php то вы можете теперь <a href="<?php echo $link; ?>">получить токен</a>
</div>
<?
include_once 'sys/inc/tfoot.php';
exit;
}
$query = array(
'q' => implode('+', explode(" ", $text)),
'count' => $default_count,
'sort' => 0,
'offset' => $offset,
'fields' => 'photo_id,verified,sex,bdate,city,country,home_town,has_photo,photo_50,photo_100,photo_200_orig,photo_200,photo_400_orig,photo_max,photo_max_orig,online,lists,domain,has_mobile,contacts,site,education,universities,schools,status,last_seen,followers_count,common_count,occupation,nickname,relatives,relation,personal,connections,exports,wall_comments,activities,interests,music,movies,tv,books,games,about,quotes,can_post,can_see_all_posts,can_see_audio,can_write_private_message,can_send_friend_request,is_favorite,is_hidden_from_feed,timezone,screen_name,maiden_name,crop_photo,is_friend,friend_status,career,military,blacklisted,blacklisted_by_mem',
'has_photo' => 1,
'age_from' => 13,
'age_to' => 70,
);
$list = $init->getData('users.search', $query);
$count = ($list['response'][0] > 1000 ? 1000 : $list['response'][0]);
$k_page = k_page($count, $default_count);
$page = page($k_page);
?>
<form action="?" method="get">
Текст: <br />
<input type="text" name="q" value="<?php echo $text; ?>" /><br />
<input type="submit" value="Искать" /><br />
</form>
<?
echo '<div class="foot">Найдено: ' . $count . '</div>';
unset($list['response'][0]);
foreach($list['response'] AS $city_id) {
if (isset($city_id['city'])) {
$city_exp[] = $city_id['city'];
}
if (isset($city_id['country'])) {
$country_exp[] = $city_id['country'];
}
}
$city = $init->getData('database.getCitiesById', array('city_ids' => implode(',', $city_exp)));
$country = $init->getData('database.getCountriesById', array('country_ids' => implode(',', $country_exp)));
$city_bd = array();
foreach($city['response'] AS $key => $value) {
$city_bd[$value['cid']] = $value['name'];
}
$city = $city_bd;
$country_bd = array();
foreach($country['response'] AS $key => $value) {
$country_bd[$value['cid']] = $value['name'];
}
$country = $country_bd;
?>
<div>
<?
foreach($list['response'] AS $file) {
?>
<div class="nav2">
<img src="<?php echo $file['photo_50']; ?>">
<a href="https://vk.com/<?php echo $file['domain']; ?>" target="_blank"><?php echo $file['first_name'];?> <?php echo $file['last_name'];?></a>
</div>
<?
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `vk_id` = '" . $file['uid'] . "'"), 0) == 0) {
$country_user = '';
$city_user = '';
$about = '';
$status = '';
$date = array(null, null, null);
$pol = ($file['sex'] == '2' ? 1 : 0);
$nick = $file['screen_name'];
if (isset($file['city']) && isset($city[$file['city']])) {
$city_user = $city[$file['city']];
}
if (isset($file['country']) && isset($country[$file['country']])) {
$country_user = $country[$file['country']];
}
if (isset($file['bdate'])) {
$date = array_merge(explode('.', $file['bdate']), $date);
}
if (isset($file['about'])) {
$about = $file['about'];
}
if (isset($file['about'])) {
$status = $file['status'];
}
$time = (time() - mt_rand(1000, 99990));
mysql_query("INSERT INTO `user` (`nick`, `pass`, `date_reg`, `time`, `date_last`, `pol`, `ank_g_r`, `ank_m_r`, `ank_d_r`, `ank_city`, `ank_o_sebe`, `ank_name`, `vk_id`, `ank_country`, `ank_family`, `rating`, `ank_lov_1`, `ank_lov_2`, `ank_lov_3`, `ank_lov_4`, `ank_lov_5`, `ank_lov_6`, `ank_lov_7`, `ank_lov_8`, `ank_lov_9`, `ank_lov_10`, `ank_lov_11`, `ank_lov_12`, `ank_lov_13`, `ank_lov_14`, `ank_orien`) VALUES ('$nick', '" . md5($nick) . "', '$time', '" . mt_rand(0, 5000) . "', '" . time() . "', '$pol', '$date[2]', '$date[1]', '$date[0]', '$city_user', '$about', '" . my_esc($file['first_name']) . "', '$file[uid]', '$country_user', '" . my_esc($file['last_name']) . "', '" . mt_rand(0, 500) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 1) . "', '" . mt_rand(0, 3) . "')");
$user_id = mysql_insert_id();
if ($user_id) {
if ($status) {
mysql_query("INSERT INTO `status`(`id_user`, `msg`, `time`) VALUES ('$user_id', '" . my_esc($status) . "', '$time')");
$st = mt_rand(1, 7);
mysql_query("INSERT INTO `liders` (`id_user`, `stav`, `msg`, `time`, `time_p`) values('$user_id', '$st', '" . my_esc($status) . "', '" . ($time + 86400 * $st) . "', '$time')");
}
$guest = $init->getData('wall.get', array('owner_id' => $file['uid'], 'domain' => $file['screen_name'], 'count' => 2, 'filter' => 'all'));
if (isset($guest['response'][1]) && $guest['response'][1]['text']) {
mysql_query("INSERT INTO `guest`(`id_user`, `msg`, `time`) VALUES ('$user_id', '" . my_esc(str_replace('<br>', "n", $guest['response'][1]['text'])) . "', '$time')");
}
if (isset($guest['response'][2]) && $guest['response'][2]['text']) {
mysql_query("INSERT INTO `notes`(`name`, `id_user`, `msg`, `time`) VALUES ('" . (rez_text2(str_replace('<br>', "n", $guest['response'][2]['text']))) . "', '$user_id', '" . my_esc(str_replace('<br>', "n", $guest['response'][2]['text'])) . "', '$time')");
}
if (isset($file['photo_50']) && mt_rand(0, 3) != 1) {
mysql_query("INSERT INTO `gallery`(`id_user`, `name`, `time_create`, `time`) VALUES ('$user_id', 'Личные фотографии', '$time', '$time')");
$gallery_id = mysql_insert_id();
mysql_query("INSERT INTO `gallery_foto`(`id_gallery`, `name`, `ras`, `type`, `id_user`, `avatar`, `time`) VALUES ('$gallery_id', 'Моя фотография', 'jpg', 'image/jpeg', '$user_id', '1', '$time')");
$photo_id = mysql_insert_id();
$photo50 = @file_get_contents($file['photo_50']);
$photo200 = @file_get_contents($file['photo_200']);
$photo_max = @file_get_contents($file['photo_max_orig']);
$upload = false;
if ($photo50 && @file_put_contents(H.'sys/gallery/50/' . $photo_id . '.jpg', $photo50)) {
if (@file_put_contents(H.'sys/gallery/128/' . $photo_id . '.jpg', $photo200)) {
if (@file_put_contents(H.'sys/gallery/640/' . $photo_id . '.jpg', $photo_max)) {
if (@file_put_contents(H.'sys/gallery/foto/' . $photo_id . '.jpg', $photo_max)) {
$upload = true;
}
}
}
}
if (!$upload) {
mysql_query("DELETE FROM gallery_foto WHERE id = '$photo_id'");
@unlink(H.'sys/gallery/50/' . $photo_id . '.jpg');
@unlink(H.'sys/gallery/128/' . $photo_id . '.jpg');
@unlink(H.'sys/gallery/640/' . $photo_id . '.jpg');
@unlink(H.'sys/gallery/foto/' . $photo_id . '.jpg');
}
}
}
?><div class="nav1"><?
echo 'Ник: <b>' . $nick . '</b><br />';
echo 'Дата рождения: ' . $date[0] . '-' . $date[1] . '-' . $date[2] . '<br />';
echo 'Cтрана: ' . $country_user . '<br />';
echo 'Город: ' . $city_user . '<br />';
echo 'Пол: ' . $pol . '<br />';
echo 'О себе: ' . $about . '<br />';
?></div><?
if ($status) {
?>
<div class="st_1"></div><div class="st_2"><?php echo $status; ?></div>
<?
}
unset($country_user, $city_user, $pol, $date, $nick, $about, $status, $user_id);
}
}
?></div>
<?
if ($k_page > 1) echo str('?q=' . $text . '&', $k_page, $page);
include_once 'sys/inc/tfoot.php';