| Server IP : 45.94.215.241 / Your IP : 216.73.216.122 Web Server : Apache/2.4.66 (Ubuntu) System : Linux srv2937474766 7.0.0-28-generic #28-Ubuntu SMP PREEMPT_DYNAMIC Sun Jun 21 01:01:36 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.5.4 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/nikooacademy_crm/students/ |
Upload File : |
<?php
$cookie_file = "./cookies.txt"; // Use absolute path for cookies
$username = '09126276625';
$password = 'aA@09126276625';
// Moodle login page URL
$moodle_login_url = "https://lms.nikoo-academy.com/login/index.php";
// Step 1: Get the login page to extract the token
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $moodle_login_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
$response = curl_exec($ch);
// Extract login token
preg_match('/<input type="hidden" name="logintoken" value="(.*?)"/', $response, $matches);
if (isset($matches[1])) {
$login_token = $matches[1];
echo "Login Token Found: $login_token\n";
} else {
die("Failed to get login token!\n");
}
// Step 2: Send login request with token
$post_fields = http_build_query([
"username" => $username,
"password" => $password,
"logintoken" => $login_token
]);
curl_setopt($ch, CURLOPT_URL, $moodle_login_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
curl_close($ch);
// Step 3: Check if login was successful
if (strpos($response, 'loginerrormessage') !== false) {
echo "Login failed! Check username/password.\n";
} else {
echo "Login successful!\n";
}
// Debugging
error_log(print_r($_SERVER, true));
?>