1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
| <?php
$time = time() + 3600*0;
$font = 'tahoma.ttf';
$font_bold = 'tahomabd.ttf';
$informer = "Реклама просто реклама!";
//_____НАСТРОЙКИ_____\\
/*
Чтобы получить токен -- перейдите по ссылке, разрешните доступ и из адресной строки скопируйте занчение access_token
http://oauth.vk.com/authorize?response_type=token&client_id=3213852&scope=photos,friends,offline,wall,messages
*/
$token = '80d615eb031c59b2fed7add22908a9097a56ca11861d267fd6a666499804fede4e24986209dc786158f12'; //Токен
$skype = 'trojan_info'; //Логин в скайпе
$icqnum = '77765554'; //номер ICQ
#################Шрифт###################################
function imagegettextsize($image,$sizze,$angle,$font_file,$texxt)
{
$arr = imagettftext($image,$sizze,$angle,-1000,-1000,0,$font_file,$texxt);
return $arr[2]-$arr[0];
}
#########################################################
##################Печать текста##########################
function print_text ($image, $x, $y, $left, $size, $color, $text, $font_file, $angle)
{
/*$text = iconv("windows-1251", "UTF-8",$text);*/
if ($left)
$x = 200 - $x - imagegettextsize($image,$size,$angle,$font_file,$text);
$color = substr($color, 1, 10);
$color1 = substr($color, 0, 2);
$color2 = substr($color, 2,2);
$color3 = substr($color, 4,2);
$color1 = base_convert($color1,16,10);
$color2 = base_convert($color2,16,10);
$color3 = base_convert($color3,16,10);
$color = imagecolorallocate($image, $color1, $color2, $color3);
imagettftext($image,$size,$angle,$x,$y,$color,$font_file,$text);
}
########################################################
##################Рандомное фото########################
function getphoto()
{
$url = "bg";
if (is_dir($url)) {
if ($dir = opendir($url)) {
while (false !== ($file = readdir($dir))){
if ($file != "." && $file != "..") {
$kol++;
}
}
closedir($dir);
}
}
$foto =rand (1, $kol++);
$foto ="bg/foto".$foto.".png";
return $foto;
}
#########################################################
####################################################
function get_content()
{
$date = date("d/m/Y");
$link = "http://www.cbr.ru/scripts/XML_daily.asp?date_req=$date";
$fd = fopen($link, "r");
$text="";
if (!$fd) echo "Запрашиваемая страница не найдена";
else
{
while (!feof ($fd)) $text .= fgets($fd, 4096);
}
fclose ($fd);
return $text;
}
$content = get_content();
$pattern = "#<Valute ID=\"([^\"]+)[^>]+>[^>]+>([^<]+)[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>([^<]+)[^>]+>[^>]+>([^<]+)#i";
preg_match_all($pattern, $content, $out, PREG_SET_ORDER);
$dollar = "";
$euro = "";
foreach($out as $cur)
{
if($cur[2] == 840) $dollar = str_replace(",",".",$cur[4]);
if($cur[2] == 978) $euro = str_replace(",",".",$cur[4]);
}
$dollar = "".$dollar." руб."; //курс валют , рег. вместо сообщений и онлайна
$euro = "".$euro." руб.";
####################################################
function todate ($d,$m,$y)
{
global $time;
return round((mktime(0,0,0,$m,$d,$y)-$time)/(3600*24),0);
}
#########################################################
$q[]="";
$q[]="января";
$q[]="февраля";
$q[]="марта";
$q[]="апреля";
$q[]="мая";
$q[]="июня";
$q[]="июля";
$q[]="августа";
$q[]="сентября";
$q[]="октября";
$q[]="ноября";
$q[]="декабря";
//-- определяем массив для дней недели --
$e[0]="воскресенье";
$e[1]="понедельник";
$e[2]="вторник";
$e[3]="среда";
$e[4]="четверг";
$e[5]="пятница";
$e[6]="суббота";
// ---- считываем месяц
$m=date('m');
if ($m=="01") $m=1;
if ($m=="02") $m=2;
if ($m=="03") $m=3;
if ($m=="04") $m=4;
if ($m=="05") $m=5;
if ($m=="06") $m=6;
if ($m=="07") $m=7;
if ($m=="08") $m=8;
if ($m=="09") $m=9;
// ---- считываем день недели
$we=date('w');
// ---- считываем число
$chislo=date('d');
// — извлекаем день недели
$den_nedeli = $e[$we];
// — извлекаем значение месяца
$mesyac = $q[$m];
##########################################################
function get_calend($link)
{
$s=file_get_contents($link);
preg_match_all('#write\("(.*?)"\)#',$s,$matches);
foreach($matches[1] as $key=>$str)
{
if ($key==count($matches[1])-2) break;
if ($key==9) break;
$str = strip_tags($str);
if (strlen($str)>1)
{
$i++;
$str = '- '.$str;
$str=wordwrap($str,32,"\n ");
if ($i>=3)
{
$r .= $str . "\n";
}
}
}
return $r;
}
$calend = get_calend('http://www.calend.ru/img/export/informer_new_3.js');
$calend = iconv("windows-1251", "UTF-8",$calend);
####################Погода###############################
$file = file_get_contents("http://informer.gismeteo.ru/rss/27612.xml");
/*$file = iconv("UTF-8", "windows-1251",$file);*/
preg_match_all("#<item.*?>(.*?)</item>#is", $file, $items);
foreach($items[1] as $item)
{
preg_match("#<title>(.*?)</title>#is", $item, $title);
$name = explode(":", $title[1]);
$date = $date[1];
preg_match("#<description>(.*?)</description>#is", $item, $descr);
$descr = preg_replace("#(\d{1,2,3}\.\.-\d{1,2,3} С).*#i", "$1", $descr[1]);
preg_match("#<enclosure url=(['\"])(.*?)\\1#is", $item, $img);
$data[] = $dat;
}
$dat['descr'] = $descr;
$tt = explode("С,", $dat['descr']);
$tt = explode(".,", $tt[1]);
$t = explode("температура", $dat['descr']);
$t = explode(",", $t[1]);
$t = explode("..", $t[0]);
$t ="".$t[0]." °C"; //температура
$name = $name[0]; //Город
$pogodaimg = $img[2];// картинка
$davlenie = $tt[0]; // давление
$veter = $tt[1]; // ветер
#########################################################
addlog('Start!');
//Ключ проверяющий первый запуск или нет
$firstLaunch = true;
while ($firstLaunch) {
//Получаем нужные данные с ВК шечки
//Получаем количество новых сообщений
addlog('Get inform');
$getMsg = api('messages.get','access_token='.$token.'&filters=1');
$msgCount = $getMsg['response'][0];
//Получаем количество онлайн юзеров
$getOnline = api('friends.getOnline', 'access_token='.$token);
$onlineCount = count($getOnline['response']);
//Получаем количество заявок
$getRequests = api('friends.getRequests', 'access_token='.$token.'&count=1000');
$requestCount = count($getRequests['response']);
//А тут уже работам с созданием пикчи
//Клеим фон и интерфейс
$path = dirname(__FILE__);
$top = imagecreatefrompng($path.'/bkgrnd.png');
$imag = getphoto();
$size = getimagesize($imag);
$image = imagecreatefrompng($imag);
imagecopyresampled($image, $top, 0, 0, 0, 0, $size[0], $size[1], $size[0], $size[1]);
############Добавляем статусы месенджеров################
$num = file_get_contents("http://mystatus.skype.com/$skype.num");
if($num==0) $skypeimg=$path.'/etc/4.png';
elseif($num==1) $skypeimg=$path.'/etc/4.png';
elseif($num==2) $skypeimg=$path.'/etc/1.png';
elseif($num==3) $skypeimg=$path.'/etc/2.png';
elseif($num==4) $skypeimg=$path.'/etc/4.png';
elseif($num==5) $skypeimg=$path.'/etc/3.png';
elseif($num==6) $skypeimg=$path.'/etc/4.png';
#########################################################
$fp = fsockopen ("status.icq.com", 80, &$errno, &$errstr, 30) or die("[ERROR - Could not connect to server (status.icq.com)]");
fputs($fp, "GET /online.gif?icq=$icqnum&img=5&online= HTTP/1.0\n\n");
while(!feof($fp) && !$icq_finished) {
$line = fgets ($fp,128);
if (substr($line,0,9) == 'Location:') {
if (substr($line,13,11) == 'online1.gif') { // online
$imgicq = imagecreatefrompng($path.'/etc/36.png');
$icq_finished = true;
} else {
$imgicq = imagecreatefrompng($path.'/etc/48.png');
$icq_finished = true;
}
}
}
fclose($fp);
#########################################################
$skypeimg = imagecreatefrompng($skypeimg);
imagecopy($image,$skypeimg,21,58,0,0,25,25);
imagecopy($image,$imgicq,156,60,0,0,25,25);
##################Пишем текст ^_^########################
####################################################################
print_text($image,21,115,0,7.5, '#FFFFFF', '',$font,0);
print_text($image,21,142,0,7.5, '#FFFFFF',$informer,$font_bold,0);
print_text($image,38,200,0,7.5, '#FFFFFF', 'Колличество сообщений:',$font,0);
print_text($image,20,200,1,7.5, '#FFFFFF',$msgCount,$font_bold,0);
print_text($image,38,213,0,7.5, '#FFFFFF', 'Колличество заявок:',$font,0);
print_text($image,20,213,1,7.5, '#FFFFFF',$requestCount,$font_bold,0);
print_text($image,38,230,0,7.5, '#FFFFFF', 'Друзья онлайн:',$font,0);
print_text($image,20,230,1,7.5, '#FFFFFF',$onlineCount,$font_bold,0);
#######################################################################
print_text($image,14,426,0,24,'#FFFFFF', $t,$font,0);
print_text($image,25,398,0,12, '#FFFFFF', $name,$font_bold,0);
print_text($image,16,438,0,8.9, '#FFFFFF', $davlenie,$font,0);
print_text($image,16,450,0,8.9, '#FFFFFF', $veter,$font,0);
$pogoda = imagecreatefrompng($pogodaimg);
imagecopy($image,$pogoda,130,386,0,0,55,55);
##########################################################
print_text($image,19,271,0,8, '#FFFFFF',$calend,$font,0);
print_text($image,60,476,0,8, '#000000', 'WellNetQety',$font_bold,0);
print_text($image,60,490,0,8, '#FFFFFF', 'vk.com/bobttz',$font_bold,0);
#######################################################
print_text($image,52,82,0,25, '#FFFFFF', date('H:i', $time),$font_bold,0);
print_text($image,19,99,0,9, '#FFFFFF', $chislo .' '.$mesyac,$font_bold,0);
print_text($image,17,99,1,9, '#FFFFFF', $den_nedeli,$font_bold,0);
//Сейвим результ
imagepng($image, $path.'/avatar.png');
//Асвабаждаем рысурсы
//imagedestroy($image);
//Проверяем, елси это первый запуск, то не нужно, если нет, дропаем предыдущее фото
if (!$firstLaunch) {
addlog('Delete old avatar!');
$getAllPhoto = api('photos.getProfile', 'access_token='.$token);
$infLastPhoto = end($getAllPhoto['response']);
api('photos.delete', 'pid='.$infLastPhoto['pid'].'&access_token='.$token);
}
//А тут мы будем грузить фоточку
//Получаем url для аплоада
addlog('Upload avatar!');
$getUploadServer = api('photos.getProfileUploadServer', 'access_token='.$token);
$uploadUrl = $getUploadServer['response']['upload_url'];
//Загружаем
$uploadPhoto = curl($uploadUrl, array('photo' => '@'.$path.'/avatar.png'));
$uploadJson = json_decode($uploadPhoto, true);
//Сохраняем
$savePhoto = api('photos.saveProfilePhoto', 'access_token='.$token.'&server='.$uploadJson['server'].'&photo='.$uploadJson['photo'].'&hash='.$uploadJson['hash']);
//Получаем запись о обновление фото
$getWall = api('wall.get','count=1&access_token='.$token);
$wllMsgId = $getWall['response'][1]['id'];
//Удаляем запись о обновление
api('wall.delete', 'post_id='.$wllMsgId.'&access_token='.$token);
//Задаём ключ, который говорит что мы уже грузили фото
$firstLaunch = false;
addlog('Done!');
sleep(300); //регулируем параметры обновления
}
//Апишечка
function api($method, $parametrs) {
$getApi = curl('https://api.vk.com/method/'.$method.'?'.$parametrs);
return json_decode($getApi, true);
}
//Лог
function addlog($text){
echo date('H:i:s: ').$text.PHP_EOL;
}
//Курлик
function curl($url, $post = false) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4 AlexaToolbar/alxg-3.1');
if ($post) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
$response = curl_exec ($ch);
curl_close($ch);
return $response;
}
?> |