Код: Выделить всё
<?phprequire 'vkapi.class.php';include('bd.php'); $app_id = '*******';$api_secret = 'sretdtgdcght756ttget'; $viewer_id = $_POST['viewer_id'];$auth_key = $_POST['auth_key'];$gol = $_POST['gol'];$uid = $viewer_id;$vote = $gol; mysql_connect($db_host, $db_user, $db_password) or die (mysql_error());mysql_select_db($db_name) or die (mysql_error());mysql_query("SET NAMES 'utf8'"); $real_key = md5($api_id."_".$viewer_id."_".$secret_key); if($vote>0){$vote2=$vote*100;} if ($auth_key == $real_key){ function get_url($query) {$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $query);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_TIMEOUT, 10);return curl_exec($ch);curl_close($ch);} function get_url2($query) {$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $query);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_TIMEOUT, 10);return curl_exec($ch);curl_close($ch);} $api = new VkApiNode($app_id, $api_secret);$query = $api->getBalance($uid);$user_balance = new SimpleXMLElement(get_url($query)); if ($user_balance->balance >=$vote2) {get_url($query = $api->withdrawVotes($uid, $vote2));get_url2($query = $api->addRating($uid, $vote));} else echo "Error 2. Not Enought votes";} else echo "Error. Transaction canceled."; ?>