Logging system safety
This probably makes integration and debugging harder:


if ($_GET['api']!=$apiKey) {
   header('HTTP/1.0 404 Not Found');
   die();
}



The error message is misleading, if someone use an older or wrong API key they probably will spend some time searching the error in a wrong place since it indicates that the URL is wrong, not the key. 403 Forbidden would be more convenient here.
This should be in a configuration file, it might change more often than the code itself:


$apiKey='foobar123';


This generates a random number:


$k=rand(1,10);



Documentation of mt_rand says the following:


  mt_rand — Generate a better random value


So I guess using mt_rand would we better. Furthermore, the linked page contains another interesting thing:


  [...]
  
  Caution
  
  This function does not generate cryptographically secure values, 
  and should not be used for cryptographic purposes. If you need a 
  cryptographically secure value, consider using openssl_random_pseudo_bytes() instead.


It really depends on the application and the sensitivity of your data which is more appropriate.
This usually referred as one-time password:


  one-use passwords

This check could be at the beginning of the script:


if (!isset($_POST['ip'],$_POST['ip'])) {echo 'error'; die();}



It's unnecessary to create an one-time password if the ip is empty.

Additionally, I guess the following is the same:

if (!isset($_POST['ip'])) {echo 'error'; die();}

You could eliminate the comment here with better variable naming:


$ile=12; //char number



Just rename it to $passwordLength.

See also: Clean Code by Robert C. Martin, Bad Comments, p67: Don’t Use a Comment When You Can Use a Function or a Variable
Two typos:


$adres should be $address
$dane to $done

I'd rename $sessi to a descriptive name. What does this variable store, what's its purpose? Put that into the name.
I'd change log to something more descriptive here:


$_SESSION[$sessi]="log";



logged_in would be easier to understand since it describes a state not an action (like log).