Answer the question
In order to leave comments, you need to log in
How to speed up php script?
There is a database in it of 100-1000 accounts. And each account must perform some action.
<?php
set_time_limit(0);
$res=mysqli_query($CONNECT, "SELECT * FROM `account`");
while($row=mysqli_fetch_assoc($res)){
$login=$row['login'];
$likes=trim($row['id']);
$account=trim($row['id_account']);
$user=trim($row['id_users']);
$p1=trim($row['proxy']);
$p2=trim($row['proxy_login']);
if($row['work']==1){
if(trim($row['like'])==1)
{
$respons=send('http://site.ru/elike','',1,$user,$account,$p1,$p2);
preg_match('/points\'>(.*?)</', $respons, $balance);
$respons=send('http://site.ru/wait.php','',1,$user,$account,$p1,$p2);
preg_match('/link=(.*?)\n/', $respons, $like);
if ($like[1]==''){
echo $login.' нету лайков<br>';
}else {
$respons=send(trim($like[1]),'',1,$user,$account,$p1,$p2);
$last=$like[1];
preg_match('/media\?id=(.*?)"/i', $respons, $id);
$respons=like('https://www.instagram.com/web/likes/'.trim($id[1]).'/like/',1,0,$user,$account,$p1,$p2);
$json = json_decode($respons);
if ($json->status=='ok'){
mysqli_query($CONNECT, "UPDATE `account` SET `balance` = '$balance[1]' WHERE `id` = '$likes'");
mysqli_query($CONNECT, "UPDATE `account` SET `last` = '$last' WHERE `id` = '$likes'");
mysqli_query($CONNECT, "UPDATE `account` SET `last_work` = 'like' WHERE `id` = '$likes'");
$respons=send('http://socgain.com/check/check_likes.php','',1,$user,$account,$p1,$p2);
echo $login.' лайк<br>';
}
else {
echo $login.' ошибка<br>';
}
}
}
}
}
?>
Answer the question
In order to leave comments, you need to log in
the script hangs due to the end of the timeout (i.e. the curl takes too long to receive a response from the server)
1. mysqli_query($CONNECT, "SELECT * FROM `account`") add LIMIT
2.
mysqli_query($CONNECT, "UPDATE `account` SET `balance` = '$balance[1]' WHERE `id` = '$likes'");
mysqli_query($CONNECT, "UPDATE `account` SET `last` = '$last' WHERE `id` = '$likes'");
mysqli_query($CONNECT, "UPDATE `account` SET `last_work` = 'like' WHERE `id` = '$likes'");
curl spends a lot of time connecting, start likes in small batches of 10 accounts and accurately measure request time, processing time per account. Suddenly at you there indexes do not stand.
They rightly said about trim, the data in the database should already be cleared, although this, of course, is saving on matches ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question