Last active
May 27, 2017 21:06
-
-
Save remixer-dec/f35ab2e5bd375b364267b529d1af3102 to your computer and use it in GitHub Desktop.
online stats cron standalone module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$GID = 1;//id группы | |
$UID = 1;//id того, кому слать стату | |
$token = "";//токен с offline и без прав | |
function wflog($txt,$rew){ //запись в файл | |
if($rew) | |
file_put_contents("xd.txt", $txt.PHP_EOL, FILE_APPEND); | |
else | |
file_put_contents("xd.txt", $txt.PHP_EOL); | |
} | |
function vkapi($method,$token='',$parameters='',$post=false){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL,"https://api.vk.com/method/$method?access_token=$token&$parameters&v=3.0"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
if($post!=false){ | |
curl_setopt($ch,CURLOPT_POST, true); | |
curl_setopt($ch,CURLOPT_POSTFIELDS, $post); | |
} | |
$result = curl_exec($ch); | |
curl_close($ch); | |
return $result; | |
} | |
$now=Date('H:i'); | |
$lul=json_decode(vkapi('users.search',$token,"online=true&group_id=$GID&count=0")); | |
if($lul->response){ | |
wflog($now.": ".$lul->response[0],true); | |
echo "logged ".$lul->response[0]." <br>"; | |
} | |
else { | |
echo "wtf<br>"; | |
} | |
if($now=="00:00"){ | |
$s_file=file("xd.txt"); | |
$strtxt = implode('',$s_file); | |
$crstat=urlencode($strtxt); | |
vkapi('messages.send',$token,"user_id=$UID&message=$crstat"); | |
file_put_contents("xd.txt", ""); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment