Add IP address via variable.
-
Hey there,
first of all, thanks for the plugin. It works very well and i like the easy way, to restrict the access off the Website.
The server, the website is running on is standing in my home-network, and i want, that users, which have the same public ip adress like the server can access the website without any login. In the context, all user, which are using the internet at home.
I created following code in the wp-config. php:
// Rufe den checkip.dyndns.org-Dienst auf und speichere die Rückgabewerte in einer Variablen $ip_address = file_get_contents('https://checkip.dyndns.org'); // Entferne alle nicht-numerischen Zeichen aus den Rückgabewerten, um nur die IP-Adresse zu erhalten $ip_address = preg_replace('/[^0-9.]/', '', $ip_address); // Speichere die IP-Adresse in einer Variablen $server_ip = $ip_address; // ?ffnet das Dokument mit schreiben $file = fopen("ipneu.txt", "w"); // Schreibt die IP-Adresse in das Dokument fwrite($file, $server_ip . "\n"); fclose($file); // Fügt die IP-Adresse zu den "erlaubten" hinzu. Restricted_Site_Access::add_ips( array( 'five' => $server_ip) );
When i run this code, i get a http 500 failure. When i comment out the “Restricted_Site_Access” my code works fine and the ip-adress is written into the document. But i have to login, also when i use the same public IP-Adress. Logical. I write the ip to the document, that i can check, that my code works well. When everything will work, i will remove this part of the code.
Sorry if there are stupid errors, I’m just starting to deal with php.
Can you help me out with that?
Thanks!
Greetings,
Luca
The page I need help with: [log in to see the link]
- The topic ‘Add IP address via variable.’ is closed to new replies.