$out .= sprintf($template, $cmd, $key->login, $content)."\n";␊ |
}␊ |
}␊ |
$out = "# indefero start" . PHP_EOL . $out . "# indefero end" . PHP_EOL;␊ |
␊ |
// We update only the part of the file between IDF_START / IDF_END comment␊ |
$original_keys = file_get_contents($authorized_keys);␊ |
if (strstr($original_keys, "# indefero start") && strstr($original_keys, "# indefero end")) {␊ |
$out = preg_replace('/(#\sindefero\sstart).+(#\sindefero\send\s\s?)/isU', ␊ |
$out, $original_keys);␊ |
} else {␊ |
$out .= $original_keys; ␊ |
}␊ |
file_put_contents($authorized_keys, $out, LOCK_EX);␊ |
}␊ |
␊ |