[Admin] tierrilopes Posted September 16, 2017 at 08:42 PM Share Posted September 16, 2017 at 08:42 PM Uma boa adição é poder gerar o argumento aleatoriamente e através de um ficheiro cron (cron nao será explicado neste tutorial) Criar um ficheiro php na localização definida do vosso arg.txt. Neste caso, supondo que o ficheiro se chama arg.php, seria assim: https://website.com/arg.txt https://website.com/arg.php Criar o ficheiro arg.php com o seguinte código: <?php //Valor minino e maximo da variavel $min=20; $max=100; //Guardar numero aleatorio na variavel $length = mt_rand($min,$max); //Funcao gerar numero aleatorio function generateRandomString($length) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } //Guardar numero aleatorio no ficheiro $myfile = fopen("arg.txt", "w") or die("Unable to open file!"); $txt = "--" . generateRandomString($length);; fwrite($myfile, $txt); fclose($myfile); ?> Para gerar um novo argumento, simplesmente abrir a localização do ficheiro php no browser, por exemplo: https://website.com/arg.php Cada vez que o ficheiro for aberto, será gerado um novo argumento. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now