Added set follower to -1 if no follower found in bio.
This commit is contained in:
parent
ac2ff8925c
commit
47b59abbd8
|
@ -101,6 +101,7 @@ function update_user_by_username($username) {
|
||||||
$dom->loadHTML($html);
|
$dom->loadHTML($html);
|
||||||
$dom->preserveWhiteSpace = false;
|
$dom->preserveWhiteSpace = false;
|
||||||
$xpath = new \DOMXPath($dom);
|
$xpath = new \DOMXPath($dom);
|
||||||
|
$changed = false;
|
||||||
foreach ($xpath->query("descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' tgme_page_description ')]/a") as $node){
|
foreach ($xpath->query("descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' tgme_page_description ')]/a") as $node){
|
||||||
$username_follows = preg_replace('/^@/', '', $node->nodeValue);
|
$username_follows = preg_replace('/^@/', '', $node->nodeValue);
|
||||||
$query = "SELECT user_id FROM users WHERE username = '" . $username_follows . "';" ;
|
$query = "SELECT user_id FROM users WHERE username = '" . $username_follows . "';" ;
|
||||||
|
@ -111,9 +112,14 @@ function update_user_by_username($username) {
|
||||||
$row = $result->fetch_assoc();
|
$row = $result->fetch_assoc();
|
||||||
$query = "UPDATE users SET follows = " . $row['user_id'] . " WHERE username = '" . $username . "';" ;
|
$query = "UPDATE users SET follows = " . $row['user_id'] . " WHERE username = '" . $username . "';" ;
|
||||||
$conn->query($query);
|
$conn->query($query);
|
||||||
|
$changed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!$changed) {
|
||||||
|
$query = "UPDATE users SET follows = -1 WHERE username = '" . $username . "';" ;
|
||||||
|
$conn->query($query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update users
|
# Update users
|
||||||
|
|
Loading…
Reference in New Issue